Project Euler 669 - The King's Banquet

Official link: https://projecteuler.net/problem=669