the python way?

Greg McIntyre greg at puyo.cjb.net
Tue Jun 7 04:27:23 EDT 2005


I like this solution. For some reason it made me want to write a Ruby
version of it. Possibly something about the title and the fact that
Ruby enthusiasts are always going on about "the Ruby way".

VOWELS = 'aeiouy'.split('')

def reinterpolate(word)
    letters = word.split('').sort_by{rand}
    vowels = letters.find_all{|l| VOWELS.include?(l) }
    consonants = letters - vowels
    return vowels.zip(consonants).map{|v, c| "#{c}#{v}" }.join('')
end

puts reinterpolate("encyclopedias")




More information about the Python-list mailing list