# Random literal number [duplicate]

I took inspiration from a challenge I did some years ago in a programming competition.

Your goal is to write a function that generates a random integer number between 0 and 150 (included), and then prints it in actual words. For example, 139 would be printed as onehundredthirtynine.

Rules:

• You cannot use any external resource, nor any library that will perform the conversion.

• The shortest answer will win.

Good luck!

## marked as duplicate by manatwork, John Dvorak, ProgramFOX, Doorknob♦, Darren StoneJan 2 '14 at 19:17

• With or without spaces? – ProgramFOX Jan 2 '14 at 18:53
• Without spaces, as you can see in the example! :) – Vereos Jan 2 '14 at 18:54
• ... Damn, I actually searched for it. Didn't use proper keywords :/ – Vereos Jan 2 '14 at 18:57
• Don't worry, neither I found it easily. (I knew another question which links to that one.) – manatwork Jan 2 '14 at 19:00

# Lua

print"four"


Highly optimized and golfed xkcd's random number generator

# An actual solution, 380

x=math.random(0,150)m=math.floor print(x==0 and"zero"or((x>99 and"onehundred"or"")..(({"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"})[x%100-9]or({[0]="",nil,"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"})[m(x/10)%10]..({[0]="","one","two","three","four","five","six","seven","eight","nine"})[x%10])))

• print"un" in French. How about just "un"? – Cees Timmerman Jan 2 '14 at 19:04
• PHP has barewords. 2 characters in PHP – John Dvorak Jan 2 '14 at 19:05
• still an invalid answer. This isn't code-trolling. – John Dvorak Jan 2 '14 at 19:06
• – Cees Timmerman Jan 2 '14 at 19:08