Solution by Finley
