Climb to America

Now that other users have helped Trump build the wall, its time for you to climb it.

This is an ascii art challenge where you need to output a climbing wall with randomly placed holds.

A climbing wall is made up of panels each of which has between 3 and 10 holds and is 5 panels high. Each panel is 4 characters high and 10 characters across

We use | to represent the side of the wall (the arête) and a - to represent the edges of panels. The corners of the panels are shown by + and the holds are shown as o.

Finally, the wall must have America! at the top and Mexico at the bottom.

Your program should take no input unless input is required to run and should output something that looks similar to the below

This is an example output:

  America!
+----------+
|  o       |
|    o o   |
| o    o   |
|  o    o  |
+----------+
|  o       |
|    o o   |
| o    o   |
|  o    o  |
+----------+
|  o       |
|    o o   |
| o    o   |
|  o    o  |
+----------+
|  o       |
|    o o   |
| o    o   |
|  o    o  |
+----------+
|  o       |
|    o o   |
| o    o   |
|  o    o  |
+----------+
Mexico


This may be confusingly set out so it's structured more clearly below

Input

Zilcho. You should take no absolutely input.

Output

An ascii-art climbing wall made up of 5 panels, each one 6 lines by 12 columns with America! centered at the top and Mexico centered at the bottom. Each panel has an identical pattern that is randomly generated by the program. The panel pattern consists of a randomly distributed random number of holds, between 3 and 10.

Rules

• No input allowed
• I would say "no builtins" but if your language has a builtin for this, I will automatically accept it as the winner.
• This is so shortest code (in bytes) wins.
• The output without holds must be exactly the same as above, again without holds.
• Random is the random defined here
• Does random mean uniformly random, or does each possible layout just need a nonzero chance of occurring, or do I just need to have at least two possibilities? – Pavel May 17 '17 at 7:04
• @Notts90 They should be the same, and pick a quantity randomly. This is mentioned in the post, but the randomness isn't defined. – Pavel May 17 '17 at 7:33
• I still think this would be a better challenge if every panel had to be different. – Shaggy May 17 '17 at 9:48
• This right here is my issue with the Sandbox. I had this challenge there for more than a month and have just decided to clear out my posts there. So I post this, thinking that every issue has been ironed out and this happens! – caird coinheringaahing May 17 '17 at 14:51
• @WORNGALL Fake news! Lies! The random is very important. Trumpscript has the BEST RANDOM GENERATOR you have ever seen. (All you have to do is link to the president's twitter feed!) – Level River St May 22 '17 at 1:10

Jelly, 65 57 bytes

First ever use of the new-fangled ⁽, a two-code-point integer string literal (⁽¥0 = 2049)

⁽¥0ṃ⁾+-W
“K2X)»Ṅø40RẊ<8X+3¤s⁵ị⁾o j@€⁾||Yṭ¢µṄ€5¡Ṗ;⁷“Ç€:;#»


Full program taking no input and printing the wall.

Try it online!

How?

⁽¥0ṃ⁾+-W - Link 1, panel separator: no arguments
⁽¥0      - literal 2049
⁾+-  - literal "+-"
ṃ     - convert 2049 to base "+-" as if they were [1,0]
W - wrap in a list   -> ["+----------+"]

“K2X)»Ṅø40RẊ<8X+3¤s⁵ị⁾o j@€⁾||Yṭ¢µṄ€5¡Ṗ;⁷“Ç€:;#» - Main link: no arguments
“K2X)»                                           - "  America!"
Ṅ                                          - print with line feed
40                                       - literal 40
R                                      - range -> [1,2,...,40]
Ẋ                                     - random shuffle
8X                                  -   random integer between 1 and 8
3                                -   literal 3
<                                    - less than? (vectorises)
⁵                             - literal 10
s                              - split into chunks of length 10
⁾o <-- a space              - literal "o "
ị                            - index into
⁾||                   - literal "||"
j@€                      - join with reversed @rguments
Y                  - join with line feeds
ṭ                 - tack left to right
µ               - call that p... (monadic chain separation)
5¡           - repeat five times:
€             -   for €ach (separator & panel)
Ṅ              -     print with trailing line feed(separator and panel):
Ṗ          - pop (just the separator now)
⁷        - literal line feed
;         - concatenate
- unused value printed
“Ç€:;#» - "   Mexico"
- implicit print

• This is the longest jelly program I have ever seen. – Pavel May 17 '17 at 7:58
• The ambiguity has been changed. I decided with 3-10 as to allow yours to stay. – caird coinheringaahing May 17 '17 at 14:55
• +1 for the )o <-- a space. Genuinely made me laugh! – caird coinheringaahing May 17 '17 at 15:52
• @Phoenix it's got shorter, but I can't help but think it should be shorter still. – Jonathan Allan May 17 '17 at 19:54
• @Satan'sSon it's almost a space-hopper! – Jonathan Allan May 17 '17 at 19:56

PHP, 138 Bytes

<?=($p=str_pad)(" America!",349,strtr(" +----------+ |0| |1| |2| |3|",str_split(str_shuffle($p($p(o,rand(3,10),o),40)),10)))." Mexico";  Try it online! Expanded <?=($p=str_pad)("  America!",349,
#fill the string till a length of 349 with
strtr("
+----------+
|0|
|1|
|2|
|3|",
# before replace the digits with strings in the array
str_split(str_shuffle($p($p(o,rand(3,10),o),40)),10)))
# make a string with o length 3- 10 fill it with spaces to length 40
# shuffle the resulting string and split it into a array of strings with length 10
."   Mexico"; # add the end


JavaScript (ES6), 194 160 bytes

(h=0,g=p=>h>2?p:g(p.replace(/ /g,_=>" o"[(h+=s=Math.random()>.8)<11&s])))=>  America!
${t=+----------+ }${g(|          |
.repeat(4)+t).repeat(5)}   Mexico


Try It

The pattern of the holds will change every 2 seconds in the Snippet below.

f=
(h=0,g=p=>h>2?p:g(p.replace(/ /g,_=>" o"[(h+=s=Math.random()>.8)<11&s])))=>  America!
${t=+----------+ }${g(|          |
.repeat(4)+t).repeat(5)}   Mexico
o.innerText=f()
setInterval("o.innerText=f()",2e3)
<pre id=o>

Explanation

• We create an anonymous function, which, although it doesn't take any input, does have 2 parameters with default values:
• h, which is given an initial value of 0; this will keep count of number of holds on the panel when we go to add them.
• g, which is a recursive function we'll use to create the random pattern of holds on the panel. We'll come back to this in a bit.
• In the main function body, we output a template literal, starting with  America!\n.
• We then create the panel divider (+----------+\n) and assign it to variable t, adding it to the output in the process.
• Next, we create a single line of the panel (| |\n), repeat it 4 times and append t.
• We call g, passing the string from the step above as an argument, via parameter p.
• Now, for the hold pattern. Within g:
• We check to see if h>2 (i.e., do we have 3 or more holds).
• If so, we return the string p.
• If not, we call g again, this time passing a modified copy of p as the argument.
• The modified copy of p has the replace method used on it, replacing all <space> characters with a <space> or an o by referencing the character index (0 or 1) of the string <space>o.
• We determine the character index by
1. Calling Math.random(), which returns a decimal number between 0 & 1, exclusive.
2. Checking if that is greater than .8. With their being 40 spaces in the panel and there only being a maximum of 10 holds, doing this improves the distribution of the holds across the panel (.75 would be more accurate, but, hopefully, you'll allow me the concession for the sake of saving a byte!).
3. The boolean of that check is assigned to variable s.
4. s is coerced to an integer (0 or 1) and added to h.
5. We check if h is now less than 11 (i.e., do we currently have less than 10 holds) and if s was true.
6. That boolean is in turn coerced to an integer, giving us an index in the string.
• Back to our output! We repeat the string returned by g 5 times.
• And then simply add  Mexico to the end of the string to finish things off. Phew!

Alternative

And, simply because I thought it would have made a nice addition to the challenge: For only 12 extra bytes, we can have a unique pattern of holds on each panel, instead of them all being identical.

(g=(p=|          |
.repeat(4)+t,h=0)=>h>2?p:g(p.replace(/ /g,_=>" o"[(h+=s=Math.random()>.8)<11&s]),h))=>  America!
${t=+----------+ }${g()+g()+g()+g()+g()}    Mexico


Try It

Again, the patterns of the holds will change every 2 seconds.

f=
(g=(p=|          |
.repeat(4)+t,h=0)=>h>2?p:g(p.replace(/ /g,_=>" o"[(h+=s=Math.random()>.8)<11&s]),h))=>  America!
${t=+----------+ }${g()+g()+g()+g()+g()}    Mexico
o.innerText=f()
setInterval("o.innerText=f()",2e3)
<pre id=o>

Pyth - 58 57 bytes, possibly 47

Ks(b\+*\-T\+*+++b\|*dT\|4)J<.SxdmdK+3O8+*s.e?/Jk\obK5<K13


Try it

Explanation of old solution (I'll update when I have the time):

J+++b\+*\-T\+K+J*+++b\|*dT\|4=Y<.SxdmdK+3O8+*s.e?/Yk\obK5J
J+++b\+*\-T\+                                                Create the +----------+, and store as J
K+J*+++b\|*dT\|4                                Create a full panel (minus bottom border, and without holes), store as K
xdmdK                      Get indices of spaces
.S                           Create random permutation of these indices
<       +3O8                  Get first several indices (a random number from 3 to 10)
s.e?/Yk\obK     Replace space with 'o' at these indices
+*           5J   Create 5 copies, and add bottom border


I think I can get 47 while still technically following the rules:

JhO2Ks(b\+*\-T\+*+++b\|.S+*\oJ*d-TJ\|4)+*K5<K13


Here, the number of holes is still randomly chosen (from the set {4,8}) and the configuration of those holes is randomly chosen (from the set of configurations where each row is identical)

Try it

Mathematica, 201 bytes

c=Column;s=RandomSample[Tuples[{" ",o," "," "},10],4];t="+----------+";w=c[{t,c[Row/@Table[AppendTo[s[[i]],"|"];PrependTo[s[[i]],"|"],{i,Length@s}]]}];c[Flatten@{"  America!",Table[w,5],t,"   Mexico"}]

• +1 for using a language I can't test? – caird coinheringaahing May 17 '17 at 22:30
• @Satan'sSon, you can run most Mathematica programs for free here at the Wolfram Sandbox. (Paste it in and press shift-enter.) – Not a tree May 18 '17 at 0:47
• When it comes to printing, this site prints in a funny way. The output is distorted because it uses special charachters... – ZaMoC May 18 '17 at 0:54

Powershell (255 Bytes)

echo "  America!"
for($l=0;$l-lt4;$l++){$a=," "*12;$a[0]="|";$a[11]="|";$i=get-random -Max 10 -Min 6;$j=get-random -Max 5 -Min 1;$a[$i]=$a[$j]="o";$b+=($a-join"")}
for($k=0;$k-lt5;$k++){echo +----------+($b-join"n")}
echo +----------+n"   Mexico"


Python 2, 259224221 218 bytes

from random import*
b=[' ']*40
for x in sample(range(40),randint(3,10)):b[x]='o'
a=["+"+"-"*10+"+"]+['|'+''.join(o)+'|'for o in[b[x*10:x*10+10]for x in 0,1,2,3]]
print'\n'.join(['  America!']+a*5+[a[0]]+['   Mexico'])


Try it at repl.it

-35 including some hints from @Satan'sSon - thanks!

-3 with thanks to @Wondercricket

• could you save bytes by simply outputting t rather than save it to a variable and if you remove the spaces after America! and Mexico? print" America!" <NEWLINE> d,a,b,c=[" Mexico"],["+"+"-"*10+"+"],[" "]*40,0? – caird coinheringaahing May 18 '17 at 15:12
• Thanks @Satan'sSon. This was a "lunchbreak special" and can probably golf a fair bit more off it when I get time. Thanks again for the hints. – ElPedro May 18 '17 at 18:24
• You can also save a few bytes by changing your import to from random import* and remove the r. from the functions – Wondercricket May 18 '17 at 20:10
• Thanks @Wondercricket. Not sure how I managed to miss that one :) – ElPedro May 18 '17 at 20:15
• Satan was helpful! (First and last time for everything >:( – caird coinheringaahing May 18 '17 at 20:56

Python 2, 197 bytes

from random import*
n=randint(3,10)
s=list('o'*n+' '*(40-n))
shuffle(s)
t=10
S='+'+'-'*t+'+'
print'\n'.join(['  America!']+([S]+['|'+''.join(s[x:x+t])+'|'for x in range(0,40,t)])*5+[S,'   Mexico'])