ps. look out for all my other solutions for Advent of Code challenges here.
See details of the challenge here.
I also tried an implememtation using string instead of bool and there is no distinguishable difference in terms of performance. Now that we have the solve function we can answer both part 1 and part 2 really easily.
let part1 = solve 272 input
let part2 = solve 35651584 input