Update Problem1.hs - more general case