Problem 3401 · Hard

Find Circular Gift Exchange Chains

A table records who gave whom a gift and what it was worth. Find every closed loop of givers, report its length and total gift value, list each length and total combination once, largest first, and number the rows from 1.

Open the interactive visualisation