generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Code Golf Lua Challenge

Previous Thread :: Next Thread 
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:05 PM
Write a program that prints out a 5x5 grid of addition symbols. You have to write this in the smallest amount of characters as possible.
The output should look like this:

+++++
+++++
+++++
+++++
+++++

Or in Studio,

+++++ (x5)

Try to do it in less than 30 characters - I did it in 28 - Good luck :P


Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:06 PM
Spaces and new lines count as a character*


Report Abuse
RobuxLife is not online. RobuxLife
Joined: 19 Sep 2012
Total Posts: 13336
07 Mar 2017 04:06 PM
Write a program that prints out a 5x5 grid of addition symbols. You have to write this in the smallest amount of characters as possible.
The output should look like this:

+++++
+++++
+++++
+++++
+++++

Or in Studio,

+++++ (x5)

Try to do it in less than 30 characters - I did it in 28 - Good luck :P


Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:11 PM
print(string.rep(string.rep("x",5).."\n",5))
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:12 PM
print(string.rep("xxxxx".."\n",5))
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:12 PM
print(string.rep("xxxxx\n",5))
Report Abuse
Zach1102 is not online. Zach1102
Joined: 20 Aug 2010
Total Posts: 48576
07 Mar 2017 04:17 PM
python 2

print "x" * 5 * 5
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:19 PM
print(("xxxxx\n"):rep(5)) 25, there we go
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:20 PM
Oh nice! I didn't know there was a replication function!


Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:22 PM
Haha thanks, it took me a while ;)
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Mar 2017 04:22 PM
I'm fairly certain it cant be made any shorter? feel free to prove me wrong
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:25 PM
I'll play around a bit!


Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:26 PM
Your solution is actually 24! :P


Report Abuse
Zach1102 is not online. Zach1102
Joined: 20 Aug 2010
Total Posts: 48576
07 Mar 2017 04:26 PM
string.rep("XXXXX\n",5)

not sure if roblox has that library tho
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:34 PM
@zach, ROBLOX does have that library, it's same function jordan used.

string.rep = ("text"):rep()



Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Mar 2017 04:35 PM
Josh how is his solution 24? I counted 25.
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:39 PM
Ohh, I just realised - I used Studio to get the length and I just remembered it takes \n as one character.


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Mar 2017 04:40 PM
Yeah :P
next time use [[...]] for testing stuff like this accurately
Report Abuse
v1sionary is not online. v1sionary
Joined: 03 Feb 2012
Total Posts: 1981
07 Mar 2017 04:41 PM
a new line doesn't count as a character.


Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:42 PM
Oh thanks!


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Mar 2017 04:43 PM
"a new line doesn't count as a character."
Except that it does.
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:46 PM
I meant a newline created when you hit "return" such as...


for i=1,5 do
print("*****")
end

^^
two "new lines"


Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
07 Mar 2017 04:47 PM
Ignore me, I'm confusing myself now - A newline is one character.


Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Mar 2017 05:24 PM
A better challenge would be printing a 5x5 grid of a tic tac toe pattern of + and -
Report Abuse
Zach1102 is not online. Zach1102
Joined: 20 Aug 2010
Total Posts: 48576
07 Mar 2017 05:40 PM
tyn just use mod
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image