Skip to content

Instantly share code, notes, and snippets.

@tracypholmes
Last active December 8, 2016 21:54
Show Gist options
  • Save tracypholmes/53e538819a25619ead8b0b3b77c7a421 to your computer and use it in GitHub Desktop.
Save tracypholmes/53e538819a25619ead8b0b3b77c7a421 to your computer and use it in GitHub Desktop.
https://repl.it/ChPc/0 created by tracypholmes
puts "What code would you like to decrypt?"
string = gets.chomp
puts "Hi! I will solve " + string + " for you."
#0T2abr1za0c2aby
#0h2abe1zy
decode = string.split(/[0-9]/)
#puts decode
secret = decode.map { |i| i[-1]}.join
puts "Your code word is '" + secret + "' !"
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
>>> What code would you like to decrypt?
0T2abr1za0c2aby
Hi! I will solve 0T2abr1za0c2aby for you.
T
abr
za
c
aby
Your code word is 'Tracy' !
=> nil
def decode(string)
string.split(/\d/).map{ |i| i[-1] }.join
end
# 0T2abr1za0c2aby
# 0h2abe1zy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment