9th Solution

Takes forever but gets the answer. Will need to improve. Attempted to
use set(list) to reduce duplicates but required gigs of RAM.