proposed solution to Google foobar code challenge