#!/usr/bin/python3 occupied = set() with open("input") as fh: for ln in fh: s = ln.strip() bin = s.replace("F", "0").replace("B", "1").replace("L", "0").replace("R", "1") num = int(bin, base=2) occupied.add(num) for i in range(1024): if i not in occupied and i-1 in occupied and i+1 in occupied: print(i)