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
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
|
| 07 Mar 2017 04:06 PM |
Spaces and new lines count as a character*
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 07 Mar 2017 04:11 PM |
| print(string.rep(string.rep("x",5).."\n",5)) |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2017 04:12 PM |
| print(string.rep("xxxxx".."\n",5)) |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2017 04:12 PM |
| print(string.rep("xxxxx\n",5)) |
|
|
| Report Abuse |
|
|
Zach1102
|
  |
| Joined: 20 Aug 2010 |
| Total Posts: 48576 |
|
| |
|
|
| 07 Mar 2017 04:19 PM |
| print(("xxxxx\n"):rep(5)) 25, there we go |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 07 Mar 2017 04:22 PM |
| Haha thanks, it took me a while ;) |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
| |
|
JoshRBX
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
|
| 07 Mar 2017 04:26 PM |
Your solution is actually 24! :P
|
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 20 Aug 2010 |
| Total Posts: 48576 |
|
| |
|