Created
January 26, 2018 20:15
-
-
Save notian/12c59c85c3b8a4f1a116f3c03170b2f0 to your computer and use it in GitHub Desktop.
Code Golf # -> Words
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('b',''); | |
$a = ['',one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve];$b = [3=>thir,5=>fif,8=>eigh];$c = [2=>twen,4=>'for']; | |
for(;strlen($n = $argv[++$i])>0;) echo trim((''||[$T,$h,$t,$o] = str_split(str_pad($n,4,0,STR_PAD_LEFT))).((!$n)?'zero':($T?$a[$T].' thousand ':b).($h?$a[$h].' hundred ':b).(($h&&($t||$o))?'and ':b).($t>0?($t>1?(($c[$t]?:($b[$t]?:$a[$t])).'ty-'):($a[$o+$t*10]?:(($b[$o]?:$a[$o]).'teen'))):b).($t==1?b:($o?$a[$o]:b))),' -1')."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment