Result

WA

Code [DL]

def AND x, *y
  [[x, *y], [x, x]]
end
def OR x, y, z = nil
  w = z || x
  [[y, y], [w, w], [x, y, *z]]
end

q = [
[1, 0] + [?_] * 6 + [?a],
[?R],
*"bcdefghy".chars.map {|x|
  [?_] * 8 + [x]
},
*"abcdefgh".chars.map {|x|
  [x.upcase, x, x]
},
[?z, ?g, ?H], # ==>
*"abcdef".chars.flat_map {|x|
  AND(?z, x.upcase)
},
*(3..22).flat_map {|i|
  n = "%08b" % (i * (i+1) / 2)
  a, *r =
    "abcdefgh".chars.map.with_index {|x, j|
      n[j] == ?1 ? x : x.upcase
    }
  [
    *r.flat_map.with_index {|w, j|
      j == 0 ? AND(?y, a, w) : AND(?y, w)
    }[0..-2],
    *OR(?z, ?y)[1..-1] # remove two !y
  ]
},
[0, 0, 1, 1, 0, 0, 0, ?z],
[?R] + [?_] * 7 + [?a],
[?R]
]


print q.map{|x| x.join ?\s }.join ?\n

##########################################################################################


stdin

00010100
00000110
11001000
11000001
00000000
10011001
10000100
00001111
00011100
00101000
10110001
01001011
11100111
01101001
00000011
11001100
00101111
00101101
00101100
00001100
00001010
01000001
11011001
00001111
01001110
10011111
11101101
10001111
01000010
01111000
10111110
10110110
11000100
10001000
01101010
11010010
00000001
11111101
00010101
00111011
11101001
10101110
11000000
11111110
00001011
01011011
00110111
10101011
11111101
00100100

stdout

stderr

Error: Undefined sentence on line 1: def AND x, *y

strace