initial revision
add solution to problem 3
librify useful functions from prob 3