Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - Kakuro Digit Sums

Greg Bacon <[email protected]> Thu, 06 Mar 2008 08:44:52 -0600
Newsgroups gmane.comp.lang.perl.qotw.discuss
Organization Eric Conspiracy Secret Labs
Message-ID <[email protected]>
In Haskell, FWIW:

    get_digits_sum _ 0 = []
    get_digits_sum 0 _ = []
    get_digits_sum goal n = find goal n [1..9]
      where find _ _ [] = []
            find goal n (d:ds)
              | n == 1 && d == goal = [[d]]
              | otherwise = with ++ find goal n ds
                  where with = map (d:) $ find (goal - d) (n - 1) ds

Greg