http://qs321.pair.com?node_id=821055


in reply to Re: Challenge: Sorting Sums Of Sorted Series
in thread Challenge: Sorting Sums Of Sorted Series

blokhead,
Your code needs some TLC and your for (0 .. $#list) should probably be for (;;) loops. I had this idea too but felt it wasn't in the spirit of what ikegami intended (though it meets my criteria just fine).
  1. Find the lowest sum paying attention to how many times it appears, then print
  2. Find the lowest sum that is greater than the previous pass paying attention to how many times it appears, then print
  3. Repeat until there are no new values found

The best solution I have (memory/time) is 4N + M but the most memory efficient while still having a reasonable run time is 2N + M.

Cheers - L~R