# Number Lockers!

Given a positive integer < 100 (from 1 to 99, including 1 and 99), output that many lockers.

A locker is defined as the following:

+----+
|    |
|    |
|    |
| nn |
+----+


where nn is the locker number, in base 10. If there is 1-digit number, it is expressed with a 0 in front of it. For example, locker number 2 displays the number 02.

Lockers can be stacked, but only up to 2 high:

+----+
|    |
|    |
|    |
| on |
+----+
|    |
|    |
|    |
| en |
+----+


on denotes an odd number, en an even number. Lockers can also be put next to each other.

+----+----+
|    |    |
|    |    |
|    |    |
| 01 | 03 |
+----+----+----+
|    |    |    |
|    |    |    |
|    |    |    |
| 02 | 04 | 05 |
+----+----+----+


Notice that locker number 5 is an odd-numbered locker that is on the bottom. This is because when you have odd-numbered input, the last locker should be placed on the floor (because a hovering locker costs too much). The above example therefore is the expected output for n=5. n=0 should return an nothing.

Rules: Standard methods of input/output. Input in any convenient format, output as a string. Standard loopholes apply.

Test cases:

Input
Output
---------------------
1

+----+
|    |
|    |
|    |
| 01 |
+----+
--------------------- (newlines optional in case 1)
4
+----+----+
|    |    |
|    |    |
|    |    |
| 01 | 03 |
+----+----+
|    |    |
|    |    |
|    |    |
| 02 | 04 |
+----+----+
---------------------
5
+----+----+
|    |    |
|    |    |
|    |    |
| 01 | 03 |
+----+----+----+
|    |    |    |
|    |    |    |
|    |    |    |
| 02 | 04 | 05 |
+----+----+----+
---------------------
16
+----+----+----+----+----+----+----+----+
|    |    |    |    |    |    |    |    |
|    |    |    |    |    |    |    |    |
|    |    |    |    |    |    |    |    |
| 01 | 03 | 05 | 07 | 09 | 11 | 13 | 15 |
+----+----+----+----+----+----+----+----+
|    |    |    |    |    |    |    |    |
|    |    |    |    |    |    |    |    |
|    |    |    |    |    |    |    |    |
| 02 | 04 | 06 | 08 | 10 | 12 | 14 | 16 |
+----+----+----+----+----+----+----+----+


This is , so shortest code wins!

• Related – Shaggy Apr 27 '17 at 14:10
• It's time to tell the builders to put the odd lockers on the bottom. – mbomb007 Apr 27 '17 at 14:11
• Do the prepending newlines of the case 1 have to be outputted? – dzaima Apr 27 '17 at 14:30
• @ComradeSparklePony didn't impact me at all :). Sorry about the harsh tone used, just trying to help. – Magic Octopus Urn Apr 27 '17 at 18:48

# Pyth, 66 bytes

A.[Y2m+.rKXJr6j" | "++km.[\02kdkjkUT;" -|+"+*3]KJ_.T_McSQ2js[GHhH


Test suite.

# Python 2, 201191185175171166164 163 bytes

n=input()
for j in 0,1:c=n/2+n%2*j;m='+----'*c+'+\n';print['\n',m+('|    '*c+'|\n')*3+''.join('| %02d '%-~i for i in range(j,n-n%2,2)+n%2*j*[~-n])+'|\n'+m*j][c>0],


Try it Online!

• This currently fails on the first test case. – Comrade SparklePony Apr 27 '17 at 15:01
• @ComradeSparklePony Fixed – math junkie Apr 27 '17 at 15:21

for(;a&$k="01112344453"[$i++];print"$l\n")for($l="",$b="+||"[$k%3],$n=0;$n++<$a=$argn;)$l.=$i<6&$n%2&$n!=$a|$i>5&($n%2<1|$n==$a)?($l?"":"$b").["----+"," |",sprintf(" %02d |",$n)][$k%3]:"";  Try it online! # PHP, 235 Bytes for(;$i++<$a=$argn;)$r[$i==$a|1-$i&1][]=($p=str_pad)($i,2,0,0);for(;$j<6;)$l[]=($a<2&$j<3?"":[$p("+",$c=($j<3?floor:ceil)($a/2)*5+1,"----+"),$p("|",$c,"    |"),"| ".join(" | ",$r[$j/3])." |"])[$j++%3]."\n";echo strtr("01112344453",$l);


Case 1 with optional newlines

Try it online!

Expanded

for(;$i++<$a=$argn;)$r[$i==$a|1-$i&1][]=($p=str_pad)($i,2,0,0); # make an 2D array 0:odd values 1:even values and last value for(;$j<6;) # create 6 strings for each different line
$l[]=($a<2&$j<3 # if last value =1 and line number under 3 ?"" # make an empty string empty [] as alternative :[$p("+",$c=($j<3 # else make the 0 or 3 line and store the count for next line
?floor # if line number =0 count=floor ($a/2) multiply 5 and add 1 :ceil)($a/2)*5+1,"----+") # else count= ceil($a/2) multiply 5 and add 1 ,$p("|",$c," |") # make lines 1 and 4 ,"| ".join(" | ",$r[$j/3])." |"])[$j++%3]."\n"; #make lines 2 odd values and 5 even values and last value
+(i?+${r(l,c)} :"")))),s) O.innerHTML=f(I.value); <input id="I" value="5" type="number" min="0" max="99" oninput="O.innerHTML=f(this.value)"> <pre id="O"></pre> ## Cleaned up n => { r=(s,k)=>s.repeat(k); s=""; [0,1].map(i => { c = (n/2 + n%2 * i)|0; if (c) { s += "+" + r(l="----+", c) + "\n|" + r(r(" |",c) + "\n|", 3); [...Array(c).keys()].map(j => { s += ${(h = 2*j + (i + !(i & j>c-2 & n%2))) > 9 ? h:"0"+h} |;
});
s += "\n" + (i ? +\${r(l,c)}\n : "");
}
});
return s;
};


# Charcoal, 37 bytes

ＮθＦ…·¹θ«Ｆ⁵¿﹪ι²¿⁼ιθ→↗↓Ｂ⁶±⁶↗→→0Ｐ←⮌Ｉι←←↙


Try it online! Link is to verbose version of code. Explanation:

Ｎθ


Input the number of lockers into q.

Ｆ…·¹θ«


Loop over the lockers from 1 to q inclusive.

Ｆ⁵¿﹪ι²¿⁼ιθ→↗↓


Calculate the direction to the next locker, and repeat that 5 times (golfier than using jump movements).

Ｂ⁶±⁶


Draw the locker, starting at the bottom left corner. (The bottom right corner also takes 4 bytes while the top right corner takes 5. The top left corner only takes 3 bytes but then the locker number would take longer to draw.)

↗→→0


Draw the leading zero of the locker number, if necessary.

Ｐ←⮌Ｉι


Draw the locker number reversed and right-to-left, effectively right justifying it.

←←↙


Move back to the bottom left corner ready to calculate the direction to the next locker.

Edit: Later versions of Charcoal support this 32-byte solution:

Ｆ⪪…·¹Ｎ²«Ｆ⮌ι«↗→→0Ｐ←⮌Ｉκ↖↖↖↑ＵＲ⁶»Ｍ⁵χ


Try it online! Link is to verbose version of code. Explanation:

Ｆ⪪…·¹Ｎ²«


Take the numbers from 1 to the input number inclusive pairwise. (If the input number is odd the last array will only have one element.)

Ｆ⮌ι«


Loop over each pair in reverse order.

↗→→0


Draw the leading zero of the locker number, if necessary.

Ｐ←⮌Ｉι


Draw the locker number reversed and right-to-left, effectively right justifying it.

↖↖↖↑ＵＲ⁶


Move to the top left of the locker and draw it. This is also the bottom left of the next locker, so we're ready to draw the second locker of the pair if applicable.

»Ｍ⁵χ
`

Move to the next pair of lockers. (This should be before the inner loop for a saving of 1 byte but Charcoal generates incorrect output for an input of 1 for some reason.)