Skip to content

Instantly share code, notes, and snippets.

@Cin316
Created February 24, 2018 22:58
Show Gist options
  • Select an option

  • Save Cin316/5b1cd6170c54585750fb2642402a7153 to your computer and use it in GitHub Desktop.

Select an option

Save Cin316/5b1cd6170c54585750fb2642402a7153 to your computer and use it in GitHub Desktop.
TechOlympics 2018 Code Golf
let t=Int(readLine()!)!
let a=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","forteen","fifteen","sixteen","seventeen","eighteen","nineteen"]
let b=["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
if (t<20){print(a[t])} else if(t<100){print(b[t/10-2]+" "+a[t%10])} else if(t<1000){
let p=(t%100)/10
if (p<2){print(a[t/100]+" hundred "+a[t%20])} else {print(a[t/100]+" hundred "+b[p-2]+" "+a[t%10])}}
Befunge:
&&+.@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment