slix
(slix)
1
tryong to do a ROT13(http://en.wikipedia.org/wiki/Rot_13) encrypter/
decrypter.
x = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
y = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
arr = x.split(//).zip(y.split(//))
dict = Hash[*arr.flatten]
puts "Input phrase: "
phrase = gets
rotated = ""
for x in (0..phrase.length()-1)
rotated = rotated + dict[phrase[x].chr]
end
puts rotated
'+' cant convert nil into string
cant convert nil into string
puts dict[phrase[2].chr] works though...
# tryong to do a ROT13(http://en.wikipedia.org/wiki/Rot_13) encrypter/
# decrypter.
# x = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
# y = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
# arr = x.split(//).zip(y.split(//))
# dict = Hash[*arr.flatten]
# puts "Input phrase: "
# phrase = gets
if you tried this in irb, you'd see the value of phrase.
hint: gets also stores the (unwanted) ending char
(chomp the newline pls 
# rotated = ""
# for x in (0..phrase.length()-1)
# rotated = rotated + dict[phrase[x].chr]
# end
# puts rotated
···
From: notnorwegian@yahoo.se [mailto:notnorwegian@yahoo.se]
#
# '+' cant convert nil into string
# cant convert nil into string
that's the effect
dict["\n"]
#=> nil
btw, in ruby, there are many ways to skin that rot13 problem.
eg,
"testing".tr('A-MN-Za-mn-z','N-ZA-Mn-za-m')
#=> "grfgvat"
kind regards -botp