Last active
December 20, 2015 05:09
-
-
Save kristjan/6076102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# $ ./reverse_vowels.rb 'lalelilolul' | |
# lulolilelal | |
# $ ./reverse_vowels.rb 'lalelilolu' | |
# lulolilela | |
VOWELS = 'aeiouy' | |
string = ARGV[0] | |
consonants, vowels = string.scan(/([^#{VOWELS}]+)([#{VOWELS}]+)?/i).transpose | |
vowels.unshift(vowels.pop) if vowels.last.nil? | |
puts consonants.zip(vowels.reverse).flatten.join | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for s in \ | |
lalelilolulyl \ | |
laleliloluly \ | |
lalelilolul \ | |
lalelilolu \ | |
laaleeliilooluul \ | |
laaleeliilooluu \ | |
llallellillollull \ | |
llallellillollu \ | |
llaalleelliilloolluull \ | |
llaalleelliilloolluu | |
do | |
ruby reverse_vowels.rb $s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment