Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Fwd: Please Forward: Ruby Quiz Submission
James Gray
4/23/2007 4:17:00 PM
Begin forwarded message:
> From: Wolfgang Seeberg <wolfgang.seeberg@yahoo.com>
> Date: April 23, 2007 8:44:04 AM CDT
> To: submission@rubyquiz.com
> Subject: Please Forward: Ruby Quiz Submission
>
> # Usage: ruby q121.rb
> # displays all possible letter sequences for a line of morse code.
>
> Morsehash = Hash[*%w(
> a .- b -... c -.-. d -.. e . f ..-. g --.
> h .... i .. j .--- k -.- l .-.. m -- n -.
> o --- p .--. q --.- r .-. s ... t - u ..-
> v ...- w .-- x -..- y -.-- z --..
> )]
>
> Dictionary = Hash[*%w(ruby i ieee sos).collect{ | x | [x,
> 1] }.flatten]
>
> def eat(morsecode, string = "")
> if morsecode == ""
> printf " in dictionary: " if Dictionary.has_key?(string)
> puts string
> else
> Morsehash.each do | letter, code |
> if morsecode[0, code.size] == code
> eat(morsecode[code.size .. -1], string + letter)
> end
> end
> end
> end
>
> STDERR.printf "enter morse code: "
> while gets
> eat($_.tr("^---.", ""))
> end
>
> #-------------------- End ---------------------------
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
>
http://mail...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Fwd: Please Forward: Ruby Quiz Submission
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password