Question 2: A Python solution
import math import subprocess f = open('02-square-bits') bits = f.readline() s = int(math.sqrt(len(bits))) less = subprocess.Popen(['less', '-p', '[.]'], stdin=subprocess.PIPE) for i in range(s): row = bits[i * s : (i + 1) * s] row = row.replace('0', ' ').replace('1', '..') + "\n" less.stdin.write(row.encode()) less.stdin.close()