solution to problem 60 using extensions to cpp. not fast but still acceptable.