# 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!

• With or without spaces? Jan 2, 2014 at 18:53
• Without spaces, as you can see in the example! :) Jan 2, 2014 at 18:54
• ... Damn, I actually searched for it. Didn't use proper keywords :/ Jan 2, 2014 at 18:57
• Don't worry, neither I found it easily. (I knew another question which links to that one.) Jan 2, 2014 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"? Jan 2, 2014 at 19:04
• PHP has barewords. 2 characters in PHP Jan 2, 2014 at 19:05
• still an invalid answer. This isn't code-trolling. Jan 2, 2014 at 19:06
• Jan 2, 2014 at 19:08