Counting adventure by nn

a='four fiffve six seven eight nine'
b=a-'t'-'fve'
c='eleven twelffve'
n="$System.in".toLong()
p={x,y->n-->0&&println("The $x positive integer is $y.")}
q={s,i->s.tokenize()[i]}
r={x,y,z->p x+z+'th',(y?:x)+z}
s={x->9.times{p x+q('first second third '+b-~/.$/,it)+(it>2?'th':''),x+q('one two three '+a-'ff',it)}}
s''
r'ten',0,''
9.times{r q(c-'fve'+" thir $b",it),q(c-'ff',it),it>1?'teen':''}
8.times{x=q('twen thir '+b-'u',it);p x+'tieth',x+'ty';s x+'ty-'}
r'one hundred',0,''

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page