|There's more than one way to do things|
With the recent golf events lately, i've been diving back into some number theory. The one part that always most amazed me were partitions. Oddly enough, i scoured the web looking for a formula to produce a list of the partitions for a number, and came up emtpy handed. This post is in SOPW becuase this algorithm isn't correct yet, but when finished it should be a decent go.
Let's start with some code:
So firstly, the problem i'm having with the algorithm is that it doesn't return the else lists correctly. In particular it doesn't return the original [@_] part of the list. This is made obvious by running it and finding that the code returns a list including (for 5):
Note how <bold>3 2</bold> did not show up. Although Part(2) gets called, it's not returning correctly, or so it seems. i've tried to loop trace on paper, stepping through each recruse, but i think i missed something, because it should work.
Any enlightenment would be most helpful with this, yet again, after days of work, i'm blinded...
Golf: Create a subroutine (or set of subroutines) that returns a list of partitions of a number n.
My entry (which is rather long) is above if included with this snippet for removing duplicates (which could probably also be optimized). Currently i weigh in at a whopping 235 characters (without whitespace) if the following is included: