Question 2: A Python solution
import math import subprocess f = open('02-square-bits') bits = f.readline() s = int(math.sqrt(len(bits))) for i in range(s): row = bits[i * s : (i + 1) * s] row = row.replace('0', ' ').replace('1', '##') print row
import math import subprocess f = open('02-square-bits') bits = f.readline() s = int(math.sqrt(len(bits))) for i in range(s): row = bits[i * s : (i + 1) * s] row = row.replace('0', ' ').replace('1', '##') print row