n=0
for r in b"(($"*2:n+=-4|r;print([r%c*'-'or(n:=n+1)for c in b""])
Try it online!
This prints each row as its own list. The two bytestrings contain unprintable characters -- here's the code with their ASCII values shown:
n=0
for r in[21,40,40,36]*2:n+=-4|r;print([r%c*'-'or(n:=n+1)for c in[1,1,5,3,5,1,1]])
Try it online!
The r
's in [21,40,40,36]*2
correspond to the 8 rows, and the c
's in [1,1,5,3,5,1,1]
to the 7 columns. They are chosen to make a "modulo table" producing the positions of the dashes, with a dash where r%c==1
and r%c==0
elsewhere.
c
1 1 5 3 5 1 1
r %--------------
21 | 0 0 1 0 1 0 0
40 | 0 0 0 1 0 0 0
40 | 0 0 0 1 0 0 0
36 | 0 0 1 0 1 0 0
21 | 0 0 1 0 1 0 0
40 | 0 0 0 1 0 0 0
40 | 0 0 0 1 0 0 0
36 | 0 0 1 0 1 0 0
Each non-dash position is filled with the number n
, which is first incremented. Changes to n
persist between rows, so before the start of each row we decrease n
from the end of the previous row by substracting either 3 or 4, noting that it will increment by 1 before the first value is produced.
These deltas are encoded per-row by the r
's as -4|r
, which produces [-4,-3,-3,-3,-4,-3,-3,-3]
. Because this pattern repeats in 2 blocks of 4 for the 8 rows, as did the dash pattern, we write the r
's list as a four-entry list repeated twice, saving bytes.
Here are all the properties we needed the hardcoded r
's and c
's to satisfy:
-4|21 == -3
-4|40 == -4
-4|36 == -4
21%5 == 36%5 == 1
40%3 == 1
21%1 == 40%1 == 36%1 == 40%5 == 21%3 == 36%3 == 0
I found these with a brute-force search, and many other options were possible.
-1*
isn't-1
\$\endgroup\$-2*
; the original footnote is missing. \$\endgroup\$