text:
Draw the Moon Phase
Challenge
Given the phase of the moon, draw it using ASCII art.
Your program must handle new moon, waxing crescent, first quarter, waxing gibbous, full moon, waning gibbous, last quarter, and waning crescent. Your input will be an integer.
0 -> new moon
1 -> waxing crescent
2 -> first quarter
3 -> waxing gibbous
4 -> full moon
5 -> waning gibbous
6 -> last quarter
7 -> waning crescent

The ASCII art is all placed on a 16x8 grid (because character dimension ratios). You can replace . with any character and # with any other non-whitespace character.
The output for new moon should be:
................
................
................
................
................
................
................
................

For waxing crescent:
..........######
............####
.............###
.............###
.............###
.............###
............####
..........######

For first quarter:
........########
........########
........########
........########
........########
........########
........########
........########

For waxing gibbous:
......##########
....############
...#############
...#############
...#############
...#############
....############
......##########

And for full moon:
################
################
################
################
################
################
################
################

The waning crescent is just the waxing crescent with each line reversed, as with the waning gibbous and the waxing gibbous, and the first and last quarter.
Rules

Standard Loopholes Apply
You may choose to output waxing/waning in the opposite direction if you want, though it should make no difference (the graphics shown in this question are for the northern hemisphere)
Your output must be exactly as specified. Your newlines can be any reasonable line separator, and you may have a trailing newline if you would like.

Relevant xkcd.

"though it should make no difference" - saved me a byte (I hope I got it right) :)

Does it have to be ASCII art? MoonPhase["Icon"] is 17 bytes in Mathematica…

@JonathanAllan Oh nice. Well then it might make a difference :P

@lanlock4 You stated one of the reasons why I made it ASCII art. Also yes it does have to be ASCII art.

Jelly,  43 32 bytes
-7 bytes moving from bit-mask to comparison-mask
-2 bytes with some tacit programming improvements
-1 byte moving to the southern hemisphere
-1 byte - use the all-new ɓ chain separator ...its first ever use!
“>,##‘m0Dm€0ż@€4Ḷ¤Œṙɓ%4>C¹⁸:4¤?Y

Uses the characters 0 for . and 1 for #.
All cases in a test suite at Try it online!
How?
Builds a mask capturing the first four phases, and rather than reversing the lines complements the resulting values of the modulo-4 phase result when the phase div-4 is non-zero.
I originally built a bit mask, but the mask values were 0,8,12, and 14 - 0000, 1000, 1100, and 1110 - these have phase leading ones - so a comparison-mask could be used instead.
“>,##‘m0Dm€0ż@€4Ḷ¤Œṙɓ%4>C¹⁸:4¤?Y - Main link 1: number phase
“>,##‘                           - code-page index literal [62,44,35,35]
      m0                         - reflect -> [62,44,35,35,35,35,44,62]
        D                        - decimalise -> [[6,2],[4,4],[3,5],[3,5],[3,5],[3,5],[4,4],[6,2]]
         m€0                     - reflect €ach -> [[6,2,2,6],[4,4,4,4],[3,5,5,3],[3,5,5,3],[3,5,5,3],[3,5,5,3],[4,4,4,4],[6,2,2,6]]
                 ¤               - nilad and link(s) as a nilad:
               4                 -   literal 4
                Ḷ                -   lowered range -> [0,1,2,3]
            ż@€                  - zip (reverse @rguments) for €ach -> [[[0,6],[1,2],[2,2],[3,6]],[[0,4],[1,4],[2,4],[3,4]],[[0,3],[1,5],[2,5],[3,3]],[[0,3],[1,5],[2,5],[3,3]],[[0,3],[1,5],[2,5],[3,3]],[[0,3],[1,5],[2,5],[3,3]],[[0,4],[1,4],[2,4],[3,4]],[[0,6],[1,2],[2,2],[3,6]]]
                  Œṙ             - run-length decode -> [[0,0,0,0,0,0,1,1,2,2,3,3,3,3,3,3],[0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3],[0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3],[0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3],[0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3],[0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3],[0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3],[0,0,0,0,0,0,1,1,2,2,3,3,3,3,3,3]]
                                    -   i.e.: 0000001122333333  -
                                              0000111122223333  - Marking out the separate
                                              0001111122222333  - regions as filled up by
                                              0001111122222333  - the phases of the moon in
                                              0001111122222333  - the southern hemisphere.
                                              0001111122222333  -
                                              0000111122223333  -
                                              0000001122333333  -
                    ɓ            - dyadic chain separation & swap arguments, call that m
                     %4          - phase mod 4
                       >         - greater than? (vectorises across m) 1 if so 0 if not
                              ?  - if:
                             ¤   -   nilad followed by link(s) as a nilad:
                          ⁸      -     link's left argument, phase
                           :4    -     integer divide by 4
                        C        - then: complement
                         ¹       - else: identity (do nothing)
                               Y - join with newlines
                                 - implicit print

that's not a language, it's modem noise...

@Alnitak Welcome to PPCG! Did you join this PPCG.SE just so you could make that comment? ;)

JavaScript (ES6), 121 ... 103 92 bytes
f=(n,i=128)=>i--?f(n,i)+(i%16?'':`
`)+'.#.'[i%16+4*n-~-'31000013'[n&1?i>>4:1]*~-(n&2)>>4]:''

Demo

f=(n,i=128)=>i--?f(n,i)+(i%16?'':`
`)+'.#.'[i%16+4*n-~-'31000013'[n&1?i>>4:1]*~-(n&2)>>4]:''

o.innerHTML=f(0)
<input type="range" oninput="o.innerHTML=f(this.value)" value=0 min=0 max=7><pre id=o>

Aw, I wanted to give this a stab at lunchtime. Doubt I would have beaten you, though.

Haskell, 98 90 bytes
f i=do{a<-[3,1,0,0,0,0,1,3];[".#."!!div(i*4+x+[0,a-1,0,1-a]!!mod i 4)16|x<-[0..15]]++"\n"}

It loops through the rows and columns using the list monad (a do block for rows and a list comprehension for columns) and determines which character for each cell using a expression of the input (i), offset value for the row (a), and column index (x).
Saved 8 bytes by simplifying the subexpression for the true offset.

Python 2, 144 142 127 bytes
i=input()
a,b='#.'[::i/4*2-1]
i%=4
for x in range(8):y=(int(abs(x-3.5))or 1)+2;y=[y,16-y][i>2];y=[i*4,y][i%2];print(16-y)*a+b*y

Try it online!
Can definitely be golfed further, tips are appreciated :)
Golfed off 1 byte thanks to undergroundmonorail!
Golfed off many bytes thanks to ovi and Mego because I'm a fool who forgets to not use 4 spaces for codegolf :)

if i>2:y=16-y could be changed to y=[16-y,y][i>2], which is longer, but with liberal use of semicolons would allow your loop to be a one-liner to save several bytes.

PHP, 105 Bytes
for(;$i++<8;)echo($p=str_pad)($p("",[16,16-$b=_64333346[$i],8,$b][3&$a=$argn],_M[$a/4]),16,M_[$a/4])."
";

Try it online!

why not $a/4? The indexing will do the cutting. :)

@Titus i have not know it. Thank You

Mathematica, 125 bytes
s=Switch;Grid@If[1<#<6,#&,1-#&][s[m=#~Mod~4,0,0,2,1,_,1-{3.4,5}~DiskMatrix~{8,16}]s[m,1,h=Table[Boole[i>8],8,{i,16}],_,1-h]]&

Returns a grid using 1 and 0 instead of . and # respectively.
It works using two masks, one circular one and one half-shaded one, and logically combining them to get the appropriate shapes.
The two masks are made with 1-{3.4,5}~DiskMatrix~{8,16} for the circular one, and Table[Boole[i>8],8,{i,16}] for the half one. The logic is as follows:
output = f(a AND b)

where f, a and b are:

n | f    a  b
--+-----------
0 | NOT  F  ◨
1 | NOT  ○  ◧
2 | 1    T  ◨
3 | 1    ○  ◨
4 | 1    F  ◨
5 | 1    ○  ◧
6 | NOT  T  ◨
7 | NOT  ○  ◨

The logic is simulated with 1s and 0s by using multiplication for AND and x -> 1-x for NOT.
A bonus (non-ASCII) solution, for 28 bytes: IconData["MoonPhase",#/4-1]&


text:
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 code-golf 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?

@Notts90 They should be the same, and pick a quantity randomly. This is mentioned in the post, but the randomness isn't defined.

I still think this would be a better challenge if every panel had to be different.

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!

@Phoenix random has been defined in the linked page (edited in) and is the default meaning of random here. Anything else has to be defined by the OP

Would be funny to see this solved in TrumpScript

@WORNGALL unfortunately trumpscript doesn't have a random number generator :(

@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!)

@LevelRiverSt Bug report: Trumpscript RNG. Issue: RNG is biased to output "SAD!" more often than is statistically likely in natural language.

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
       ø                                         - niladic chain separation
        40                                       - literal 40
          R                                      - range -> [1,2,...,40]
           Ẋ                                     - random shuffle
                 ¤                               - nilad and link(s) as a nilad:
             8X                                  -   random integer between 1 and 8
                3                                -   literal 3
               +                                 -   add
            <                                    - 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
                                ¢                - call last link (1) as a nilad
                               ṭ                 - 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.

The ambiguity has been changed. I decided with 3-10 as to allow yours to stay.

+1 for the )o <-- a space. Genuinely made me laugh!

@Phoenix it's got shorter, but I can't help but think it should be shorter still.

@Satan'sSon it's almost a space-hopper!

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)

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

Calling Math.random(), which returns a decimal number between 0 & 1, exclusive.
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!).
The boolean of that check is assigned to variable s.
s is coerced to an integer (0 or 1) and added to h.
We check if h is now less than 11 (i.e., do we currently have less than 10 holds) and if s was true.
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)

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

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?

@Satan'sSon, you can run most Mathematica programs for free here at the Wolfram Sandbox. (Paste it in and press shift-enter.)

When it comes to printing, this site prints in a funny way. The output is distorted because it uses special charachters...

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, 259 224 221 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?

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.

You can also save a few bytes by changing your import to from random import* and remove the r. from the functions

Thanks @Wondercricket. Not sure how I managed to miss that one :)

Satan was helpful! (First and last time for everything >:(

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'])

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes