1 2 3 4
# The idea is that each morse code is encoded as a number: # "a" is mapped to 19, which in base 3 is 201, the 2 works as a dummy to keep leading 0's in place, so the real value is "01" which maps to the morse code ".-" # "b" is mapped to 189, which in base 3 is 21000, remove the 2 and the real value is "1000" which maps to the mores code "-..." ...
Ruby On Morse Code Encoder/Decoder
by lel,
October 18, 2008 15:25
1 2 3 4
a ||= Hash.new([]) # default value for non-existing keys is now an empty array, unless a was already defined a[:k] # => [] ...
Juggling ascii-numbers, bas...