Code Golf - Print all unique ways of writing a number as a sum with a lexical order

3

I found about Code Golf after writing this program and decided to post the rules here so you can try it out too. I saw this, which is a less restrictive version of my question. I've got a bit more rules which (in my opinion) make the task quite a lot more tougher.

Title says it all. If the input is 8, we should get:

8 = 8
8 = 7 + 1
8 = 6 + 2
8 = 6 + 1 + 1
8 = 5 + 3
8 = 5 + 2 + 1
8 = 5 + 1 + 1 + 1
8 = 4 + 4
8 = 4 + 3 + 1
8 = 4 + 2 + 2
8 = 4 + 2 + 1 + 1
8 = 4 + 1 + 1 + 1 + 1
8 = 3 + 3 + 2
8 = 3 + 3 + 1 + 1
8 = 3 + 2 + 2 + 1
8 = 3 + 2 + 1 + 1 + 1
8 = 3 + 1 + 1 + 1 + 1 + 1
8 = 2 + 2 + 2 + 2
8 = 2 + 2 + 2 + 1 + 1
8 = 2 + 2 + 1 + 1 + 1 + 1
8 = 2 + 1 + 1 + 1 + 1 + 1 + 1
8 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1

Unique means this 7 + 1 and this 1 + 7 is not allowed.

Lexical order means members must be sorted in descending order by the first addend. If their first addend is equal, sort them by their second addend, etc.


Objective

Lowest size program wins.


I'll post my solution after a few days or after a few of you have posted yours. Have fun!

Hristiyan Dodov

Posted 2017-01-16T18:16:43.580

Reputation: 191

Question was closed 2017-01-16T18:29:45.493

I assume this is code-golf, but you should explicitly state the winning objective somewhere in the post - otherwise, nice challenge. – FlipTack – 2017-01-16T18:22:58.817

We've had a bunch of challenges about partitions already. It's probably not a duplicate of this challenge. It might be too similar to this one though.

– None – 2017-01-16T18:24:38.613

Is any leading/trailing whitespace allowed? – Business Cat – 2017-01-16T18:29:58.167

3

Welcome to PPCG! This is a nice first challenge, but unfortunately, we've done it before. For the future, I recommend posting challenge ideas in the sandbox to get some feedback before the challenge goes live. Apart from having help looking for duplicates, you can also get feedback about other potential problems with the challenge that can be fixed before anyone starts working on or even posting answers.

– Martin Ender – 2017-01-16T18:31:07.413

@BusinessCat depends on whether people think my challenge is valid or a duplicate. – Hristiyan Dodov – 2017-01-16T18:48:26.677

@MartinEnder should I delete my challenge then? – Hristiyan Dodov – 2017-01-16T18:48:57.483

@HristiyanDodov: It's normally best to leave duplicates in place so that people can find the original challenge more easily. (For example, if you don't know the word "partition", searching for challenges like this is quite difficult; the existence of this challenge makes it easier.) – None – 2017-01-16T19:21:02.413

Here is my answer anyway (in case you're interested). What do you think? It's 326 bytes. https://jsfiddle.net/cyvbub31/

– Hristiyan Dodov – 2017-01-16T20:07:25.217

@HristiyanDodov i would suggest copying it to the sandbox and getting some feedback. I have just posted one there and will probably wait a week or so before I post here. No rush. Maybe a couple of folks in the community can help improve it (both yours and mine!). – ElPedro – 2017-01-16T23:41:02.617

No answers