Solution by Alex Mauney (@mathmauney)