first complete attempt at problem 3

this is a little bit very slow, so i don't know if it works