Skip to content

Instantly share code, notes, and snippets.

@pankoholic
Created July 2, 2012 23:19
Show Gist options
  • Save pankoholic/3036334 to your computer and use it in GitHub Desktop.
Save pankoholic/3036334 to your computer and use it in GitHub Desktop.
Speaking in Tongues (google code challange; qualification round 2012)
(1..gets.to_i).each do |i|
(0...(str = gets.to_s.downcase).length).each do |j|
if str[j] == 'a'
str[j] = 'y'
elsif str[j] == 'b'
str[j] = 'h'
elsif str[j] == 'c'
str[j] = 'e'
elsif str[j] == 'd'
str[j] = 's'
elsif str[j] == 'e'
str[j] = 'o'
elsif str[j] == 'f'
str[j] = 'c'
elsif str[j] == 'g'
str[j] = 'v'
elsif str[j] == 'h'
str[j] = 'x'
elsif str[j] == 'i'
str[j] = 'd'
elsif str[j] == 'j'
str[j] = 'u'
elsif str[j] == 'k'
str[j] = 'i'
elsif str[j] == 'l'
str[j] = 'g'
elsif str[j] == 'm'
str[j] = 'l'
elsif str[j] == 'n'
str[j] = 'b'
elsif str[j] == 'o'
str[j] = 'k'
elsif str[j] == 'p'
str[j] = 'r'
elsif str[j] == 'q'
str[j] = 'z'
elsif str[j] == 'r'
str[j] = 't'
elsif str[j] == 's'
str[j] = 'n'
elsif str[j] == 't'
str[j] = 'w'
elsif str[j] == 'u'
str[j] = 'j'
elsif str[j] == 'v'
str[j] = 'p'
elsif str[j] == 'w'
str[j] = 'f'
elsif str[j] == 'x'
str[j] = 'm'
elsif str[j] == 'y'
str[j] = 'a'
elsif str[j] == 'z'
str[j] = 'q'
end
end
puts "Case ##{i}: " + str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment