Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PERL counting words that are missing a vowel

Name: Anonymous 2011-06-04 16:02

Write a program called no_vowels.pl that will count
how many words DO NOT have an 'a' or an 'A',
how many DO NOT have an 'e' or an 'E',
how many DO NOT have an 'i' or an
'I', and so on.

The output should look like the below. 
Note that the letters must be listed in decreasing order of frequency

14000 words do not have an 'u'
11258 words do not have an 'o'
10123 words do not have an 'i'
11523 words do not have an 'a'
10111 words do not have an 'e'

Name: Anonymous 2011-06-07 1:43

#!/usr/bin/ruby
# Fuck your shit, I use awesome languages
def no_vowels(word_list) # word_list is expected to be an array
        # Containing a string of every word to be counted
  no_a, no_e, no_i, no_o, no_u = 0
  word_list.each do |cap| cap.downcase! end
  word_list.each do |word|
    no_a += 1 unless word.include? "a"
    no_e += 1 unless word.include? "e"
    no_i += 1 unless word.include? "i"
    no_o += 1 unless word.include? "o"
    no_u += 1 unless word.include? "u"
  end
  [no_a, no_e, no_i, no_o, no_u] # can be sorted later
end

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List