working on hackerrank's coin on the table, currently TLE'ing