Skip to content

Instantly share code, notes, and snippets.

@eric-wood
Created May 25, 2012 19:20
Show Gist options
  • Save eric-wood/2790007 to your computer and use it in GitHub Desktop.
Save eric-wood/2790007 to your computer and use it in GitHub Desktop.
a = morse.split(/ /)
h = {
'.-' => 'A',
'-.' => 'N',
'-...' => 'B',
'---' => 'O',
'-.-.' => 'C',
'.--.' => 'P',
'-..' => 'D',
'--.-' => 'Q',
'.' => 'E',
'.-.' => 'R',
'..-.' => 'F',
'...' => 'S',
'--.' => 'G',
'-' => 'T',
'....' => 'H',
'..-' => 'U',
'..' => 'I',
'...-' => 'V',
'.---' => 'J',
'.--' => 'W',
'-.-' => 'K',
'-..-' => 'X',
'.-..' => 'L',
'-.--' => 'Y',
'--' => 'M',
'--..' => 'Z',
'' => ' '
}
a.map { |i| h[i] }.join.gsub(/\ \ /, ' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment