|
Post by Josh on May 1, 2017 18:42:08 GMT
String ReplicationIn this Code Golf exercise, you must write a program that gets a uniform random integer from 1 to 9 and outputs the string "HelloWorld" replicated that many times. For example, the random integer is a 2, so your program should output...
HelloWorldHelloWorld Your program must work offline.
Please format your solution as the language name followed by the number of characters that your solution contains before writing out the solution in a code block.
Good luck!
|
|
Dankvisky
New Member
Veteran
5 bans and still alive. try to beat that with a single account!
Posts: 17
ROBLOX Username: Dankvisky
|
Post by Dankvisky on May 1, 2017 18:45:59 GMT
a="" for i=1,math.random(1,9) do a=a.."HelloWorld" end warn(a)
> 62 chars
|
|
|
Post by nillogic on May 1, 2017 18:51:43 GMT
RBX.Lua, 40 chars.
warn(('HelloWorld'):rep(math.random(9)))
|
|
|
Post by Josh on May 1, 2017 18:55:12 GMT
Thanks for the contributions! We'll have to see if anyone can get any shorter.
|
|
zmart
New Member
Veteran
Posts: 8
|
Post by zmart on May 1, 2017 22:06:04 GMT
NodeJS or any web inspector console with ECMAScript 2015 support (specifically while in offline mode, due to the rules of this Golf Course)
36 38 characters
'HelloWorld'.repeat(Math.random()*8+1)
Edit: I did not account for 1-9 in the original.
|
|
|
Post by Josh on May 2, 2017 6:43:31 GMT
|
|