To write a program that detects if a sentence is a pangram in Ruby, you can use the following code:
main.rb258 chars9 lines
Explanation:
is_pangram?
function takes a sentence as an input parameter.alphabet
containing all the lowercase letters of the English alphabet..downcase
and convert it to an array of characters using .chars
..uniq
and sort the array using .sort
.The above code will return true
if the sentence is a pangram and false
otherwise.
Please note that this implementation assumes the input sentence contains only valid English letters and no special characters or numbers.
gistlibby LogSnag