Decompose integer into sum of squares by hobbs

use List::Util 'sum';sub r{@a=($_,@a);if(@_){r(@_)for 0..pop}else{$r[sum map$_**2,@a]||=[grep$_,@a]}shift@a;}r 17,12,8,2;print"$_: @{$r[$_]}\n"for 1..300

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page