#!/usr/bin/python3 max = 0 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) if max < num: max = num print(s, bin, num, max)