fork(4) download
  1. def t9(t)
  2. (t.tr(" ",?`).bytes.map{|c|"09998887777666555444333222"[96-c..-1][/(.)\1*/]}*' ').gsub /(\d) (?!\1)/,'\1'
  3. end
  4.  
  5. p t9("hello world")
  6. p t9("hi")
Success #stdin #stdout 0.01s 7420KB
stdin
Standard input is empty
stdout
"4433555 555666096667775553"
"44 444"