[Question]
  [
The other day, my son asked me to build him a staircase using Lego-ish blocks. And I came up with something like this:
[![Staircase](https://i.stack.imgur.com/EzQUOm.jpg)](https://i.stack.imgur.com/EzQUOm.jpg)
Then my kid asked me for a program using the least number of bytes that generated a similar staircase in a computer screen. I am not that good at [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so I need your help. I need a program that:
* Receives a positive integer with the number of levels the staircase needs to have.
* Outputs a drawing of a staircase, with the pattern you see in the image.
The output will be in text format but the bricks can be distinguished one from another. For instance, you may use the '█' character as half a block and paint it in any color you want, or just choose any character of your choice.
Restrictions:
* Blocks need to be of three different colors, which will be used as long as possible (if input is 1 or 2 there are not enough blocks to use all three colors). If you want, you may use the '░▒▓' characters, for instance, or just select three different characters.
* No two blocks of the same color or pattern can be side to side in a single row.
My son does not really care about trailing spaces or new lines as long as a staircase is drawn.
Examples (sorry for the bad choice of characters):
```
Input: 1
Output:
██
Input: 2
Output:
██
 ▓▓
Input: 3
Output:
██
 ▓▓
██░░
Input: 5
Output:
██
 ██
██░░
 ██░░
██░░▓▓
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), 55 bytes
```
i=2
exec"print(i%2*' '+`2%i*1122`*i)[:i];i+=1;"*input()
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9PWiCu1IjVZqaAoM69EI1PVSEtdQV07wUg1U8vQ0MgoQStTM9oqM9Y6U9vW0FpJKzOvoLREQ/P/f0MDAA "Python 2 – Try It Online")
Cycles between blocks of `22, 44`, except the top row is `00`. For example, on input 10, prints
```
00
 22
2244
 2244
224422
 224422
22442244
 22442244
2244224422
 2244224422
```
Prints rows of increasing length `i=2,3,..` by creating a space for odd lengths, repeating the pattern `i` times, and trunctating to length `i`. The pattern is `2244` for all rows except the first one `i=2` for which it's `0`. This is achieved with the arithmetic expression `2%i*1122`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~21 19~~ 16 [bytes](https://github.com/DennisMitchell/jelly)
```
d2SR+%3x2⁶;ṙḂµ€Y
```
A full program printing the result.
Uses `00`, `11`, and `22` as the blocks.
**[Try it online!](https://tio.run/##ASQA2/9qZWxsef//ZDJTUislM3gy4oG2O@G5meG4gsK14oKsWf///zc)**
### How?
```
d2SR+%3x2⁶;ṙḂµ€Y - Main link: number n
             µ€  - for €ach "row" in n (i.e. for row, r = 1 to n inclusive):
d2               -   divmod 2   -> [integer-divide by 2, remainder] i.e. [r/2, r%2]
  S              -   sum        -> r/2 + r%2
   R             -   range      -> [1, 2, 3, ..., r/2 + r%2]
    +            -   add r      -> [r+1, r+2, r+3, ..., r + r/2 + r%2]
     %3          -   modulo 3   -> [r%3+1, r%3+2, r%3+0, ..., (r + r/2 + r%2)%3]
                 -   e.g.: r: 1  , 2  , 3    , 4    , 5      , 6      , 7       , ...
                             [2], [0], [1,2], [2,0], [0,1,2], [1,2,0], [2,0,1,2], ...
       x2        -   times 2 - repeat each twice (e.g. [2,0,1,2] -> [2,2,0,0,1,1,2,2]
         ⁶       -   literal space character
          ;      -   concatenate (add a space character to the left)
            Ḃ    -   r mod 2 (1 if the row is odd, 0 if it is even (1 at the top))
           ṙ     -   rotate (the list) left by (r mod 2)
               Y - join with newlines
                 - implicit print (no brackets printed due to the presence of characters)
```
[Answer]
# JavaScript (ES6), 80 bytes
```
n=>eval(`for(s=11,i=1;i++<n;)s+='\\n'+(' '+'2233'.repeat(n)).substr(i%2,i+1);s`)
```
```
f=
n=>eval(`for(s=11,i=1;i++<n;)s+='\\n'+(' '+'2233'.repeat(n)).substr(i%2,i+1);s`)
console.log(f(+prompt()))
```
---
# JavaScript (ES6), 87 bytes
Previous solution.
```
n=>[11,...Array(n).fill(' '+'2233'.repeat(n)).map((r,n)=>r.slice(n%2,n+3+n%2))].join`
`
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~22~~ ~~21~~ ~~20~~ ~~18~~ 17 bytes
Uses the interesting fact that `4^(N+2)/5 = [3,12,51,204,...] = b[11,1100,110011,11001100,...]`
```
F4NÌm5÷bDðì}r·IF,
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fzcTvcE@u6eHtSS6HNxxeU1t0aLunm87//4YGAA "05AB1E – Try It Online")
**Explanation**
```
F                     # for N in 0...input-1 do
 4                    # push 4
  NÌ                  # push N+2
    m                 # push 4^(N+2)
     5÷               # integer division by 5
       b              # convert to binary
        D             # duplicate
         ðì           # prepend a space to the copy
           }          # end loop
            r         # reverse stack
             ·        # multiply top of stack by 2
              IF      # input times do
                ,     # print with newline
```
[Answer]
# [SOGL](https://github.com/dzaima/SOGL), ~~31~~ ~~28~~ ~~27~~ 25 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
∫³2\@*O"²b“2⁵I%*r*;I»«nKp
```
Explanation:
```
∫                          iterate input times, pushing 1-indexed counter
 ³                         get 3 total copies of it on stack
  2\                       1 if divides by 2, else 0
    @*                     get that many spaces
      O                    output in a new line
       "²b“                push 1122
           2⁵I%*           multiply 1122 by 2%(iteration+1)
                r          convert to string
                 *         multiply by iteration
                  ;I»«     get one iteration variable ontop of stack
                      n    increase, floor divide by 2, multiply by 2 (gets the amount of bricks in a line)
                       Kp  split that multiplied string in pieces of that length
```
using [this technique](https://codegolf.stackexchange.com/a/124558/59183)  
Example output for 9:
```
00
 22
2244
 2244
224422
 224422
22442244
 22442244
2244224422
```
### 22 bytes
```
∫³2\@*O"²b“2⁵I%*;I»«mp
```
The command `m` has been documentated on [the 1st SOGL commit](https://github.com/dzaima/SOGL/blob/f271baa60c11a24abec684cb9406f11c287ed315/charDefsParser/data/charDefs.txt#L359), just not implemented.
[Answer]
## PHP, ~~61~~ 59
```
aa<?for(;++$i<$argn;)echo"
",str_pad(" "[~$i&1],2+$i,bbcc);
```
works pretty much like the python versions but uses all three colors if possible. No trailing new line.
```
-2 bytes by @user63956. Thanks !
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 29 bytes
```
VQI!%hN2pd)Vh/N2p*2@G%+NH3)pb
```
[Test it online!](https://pyth.herokuapp.com/?code=VQI%21%25hN2pd%29Vh%2FN2p%2A2%40G%25%2BNH3%29pb&input=7&debug=0)
**Explanations**
```
VQI!%hN2pd)Vh/N2p*2@G%+NH3)pb
VQ                               For N in range(0, input)
  I!%hN2pd)                      If N is odd, print a leading space
           Vh/N2          )      For H in range(0, N / 2 + 1)
                   @G%+NH3       Select the letter at position (N + H) % 3 in the alphabet
                 *2              Then make it a two letters string ("aa" or "bb" or "cc")
                p                Print it
                           pb    End the line by printing a new line
```
I am sure there are a lot of ways to shorten that code, but I am king of tired right now... Will try later.
[Answer]
## Batch, 125 bytes
```
@set s=█
@for /l %%i in (2,1,%1)do @call:c
:c
@set s= %s:█= %
@set s=%s:▓=█%
@set s=%s:░=▓%
@set s=%s:  =░░%
@echo %s%
```
Note: Save this in CP437 or CP850 or some such. Works by rotating the colours each time. Since I can't map over the string to perform the rotation, I use four replacements, using spaces as a temporary stage. This then also allows me to prefix a space every line, so that two spaces turn into a new block. Sample output:
```
░░
 ▓▓
░░██
 ▓▓░░
░░██▓▓
```
]