edge cases, slow problems

note: slow doesn't mean wrong. it means right as far as I can tell but
needs optimization
problem 104