I ran across this problem on Quora... How many ways can 100 be written as a sum of 7 ordered positive integers? (no repeats) The obvious brute force approach in J would be:
odo=: #: i.@(*/) NB. Odometer verb #b=.~./:~"1 a#~100=+/"1 a=.odo 7#100 |limit error: odo | #b=:~./:~"1 a#~100=+/"1 a=: odo 7#100 Of course, odo 7#100 generates 1e14 integers (100^7) which exceeds memory. So what would the most efficient way to solve this question in J? The most concise? Skip Skip Cave Cave Consulting LLC ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm