generic version to support p23
p23 generic solution to solve p24 in Phil's way
p24 solved