All pastes #926332 Raw Edit

Something

public text v1 · immutable
·published 2008-03-03 17:43 UTC
rendered paste body
Kakuro (a.k.a Cross-sums) is a kind of puzzle game:

http://en.wikipedia.org/wiki/Kakuro

In it, one fills in squares in a crossword-like grid that sum to their sums.
One can fill in the digits from 1 to 9, and no digit can be repeated twice.

Your object is to find all posssible combinations for a given sum and a given
number of squares. You'll write a function get_digits_sum($sum, $num_places),
that will return an array reference of array references, each one containing
an possible solution (in ascending order). The solutions themselves should be
in ascending order too, starting from the lowest numbers. Here are some
examples:

get_digits_sum(7, 3) => returns [[1,2,4]].

get_digits_sum(7, 2) => returns [[1,6],[2,5],[3,4]];

The daily puzzle in http://www.kakuro.com/index.php#daily (requires Flash) has
a feature to display the permutations in a similar manner.

Regards,
        
        Shlomi Fish