Cover a square with rectangles P69283


Statement
 

pdf   zip

thehtml

Suppose that you have an infinite suply of m × 2m rectangles for every natural m ≥ 1. You have to exactly cover an ℓ × ℓ square (you can choose ℓ ) by placing n of those rectangles horizontally or vertically. For instance, these are some ways for n = 2, n = 5 and n = 6:

(10,6) unit=0.6cm, linewidth=0.6

linecolor=black

[fillcolor=blue,fillstyle=solid](0,0)(0,1)(2,1)(2,0) [fillcolor=red,fillstyle=solid](0,1)(0,2)(2,2)(2,1)

[fillcolor=blue,fillstyle=solid](4,0)(4,4)(6,4)(6,0) [fillcolor=yellow,fillstyle=solid](6,0)(6,2)(7,2)(7,0) [fillcolor=red,fillstyle=solid](7,0)(7,2)(8,2)(8,0) [fillcolor=green,fillstyle=solid](6,3)(6,4)(8,4)(8,3) [fillcolor=orange,fillstyle=solid](6,2)(6,3)(8,3)(8,2)

[fillcolor=cyan,fillstyle=solid](10,0)(10,4)(12,4)(12,0) [fillcolor=orange,fillstyle=solid](10,4)(10,6)(14,6)(14,4) [fillcolor=green,fillstyle=solid](14,2)(14,6)(16,6)(16,2) [fillcolor=red,fillstyle=solid](12,0)(12,2)(16,2)(16,0) [fillcolor=yellow,fillstyle=solid](12,2)(12,3)(14,3)(14,2) [fillcolor=blue,fillstyle=solid](12,3)(12,4)(14,4)(14,3)

There are only a few n for which it is impossible to cover a square with n such rectangles. In particular, it is always possible when n % 3 = 2. Can you prove it?

Input

Input consists of several n such that n ≡ 2 (mod 3 ). Assume 2 ≤ n ≤ 62.

Output

For every n, first print a line with an ℓ between 2 and 30. Afterwards, print ℓ lines with ℓ ‍characters each. Use different digits, lowercase letters and uppercase letters to indicate each rentangle. Since there are multiple possible solutions, print any one.

Public test cases
  • Input

    2
    2
    14
    

    Output

    2
    00
    11
    6
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    8
    C3POjj42
    C3POdd42
    BBBBBBBB
    BBBBBBBB
    BBBBBBBB
    BBBBBBBB
    T1111XX5
    T1111YY5
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++