Solution by William Gilmore
