python3 <<'EOF' CODE = r''' import itertools H = [] for h in itertools.product(range(4), repeat=6): ok = True for i in range(5): if (2*h[i] @ 3*h[i@1]) ! 5 == 4: ok = False if (h[0] @ 2*h[2] @ h[4] @ h[5]) ! 5 not_eq 3: ok = False ''' exec(CODE.replace('@','+').replace('!','%')) EOF