added solution to problem 4 that works but is too slow in cljs