problem.txt lists the problem to be solved with a small sample example
main.py is my own solution code
the actual test case involved 200,000+ '2-chains', so some optimization is necessary if you want the program to have a reasonable run time.
read problem.txt for more information