b=%w[twen thir for fif six seven eigh nine] a=%w[ty one two three four five six seven eight nine ten eleven twelve]+b[1,7].map{|$_|sub('o','ou')+"teen"} puts$<.map{|l|z=[] k=-1 ("%012d"%l).gsub(/.../){n=$&.to_i n>99&&z<<x=a[n/?d]+" hundred" n%=?d n>0&&z<<x=a[n]||b[n/10-2]+"ty "[0,n%10*3]+a[n%10] x&&z<<%w[billion million thousand][k]if 3>k+=1} z*" "}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).