Enumerate Compositions

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Given a positive integer n, list all sequences of positive integers whose sum is n.

-- mitchs

Options

exec is denied

no deadline, the server will not save your submission

Sample input:_

4
5
9

Sample output:

1 1 1 1
1 1 2
1 2 1
1 3
2 1 1
2 2
3 1
4
1 1 1 1 1
1 1 1 2
1 1 2 1
1 1 3
1 2 1 1
1 2 2
1 3 1
1 4
2 1 1 1
2 1 2
2 2 1
2 3
3 1 1
3 2
4 1
5
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 2
1 1 1 1 1 1 2 1
1 1 1 1 1 1 3
1 1 1 1 1 2 1 1
1 1 1 1 1 2 2
1 1 1 1 1 3 1
1 1 1 1 1 4
1 1 1 1 2 1 1 1
1 1 1 1 2 1 2
1 1 1 1 2 2 1
1 1 1 1 2 3
1 1 1 1 3 1 1
1 1 1 1 3 2
1 1 1 1 4 1
1 1 1 1 5
1 1 1 2 1 1 1 1
1 1 1 2 1 1 2
1 1 1 2 1 2 1
1 1 1 2 1 3
1 1 1 2 2 1 1
1 1 1 2 2 2
1 1 1 2 3 1
1 1 1 2 4
1 1 1 3 1 1 1
1 1 1 3 1 2
1 1 1 3 2 1
1 1 1 3 3
1 1 1 4 1 1
1 1 1 4 2
1 1 1 5 1
1 1 1 6
1 1 2 1 1 1 1 1
1 1 2 1 1 1 2
1 1 2 1 1 2 1
1 1 2 1 1 3
1 1 2 1 2 1 1
1 1 2 1 2 2
1 1 2 1 3 1
1 1 2 1 4
1 1 2 2 1 1 1
1 1 2 2 1 2
1 1 2 2 2 1
1 1 2 2 3
1 1 2 3 1 1
1 1 2 3 2
1 1 2 4 1
1 1 2 5
1 1 3 1 1 1 1
1 1 3 1 1 2
1 1 3 1 2 1
1 1 3 1 3
1 1 3 2 1 1
1 1 3 2 2
1 1 3 3 1
1 1 3 4
1 1 4 1 1 1
1 1 4 1 2
1 1 4 2 1
1 1 4 3
1 1 5 1 1
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5 2
6 1
7
1 1 1 1 1 1
1 1 1 1 2
1 1 1 2 1
1 1 1 3
1 1 2 1 1
1 1 2 2
1 1 3 1
1 1 4
1 2 1 1 1
1 2 1 2
1 2 2 1
1 2 3
1 3 1 1
1 3 2
1 4 1
1 5
2 1 1 1 1
2 1 1 2
2 1 2 1
2 1 3
2 2 1 1
2 2 2
2 3 1
2 4
3 1 1 1
3 1 2
3 2 1
3 3
4 1 1
4 2
5 1
6
1 1 1 1 1
1 1 1 2
1 1 2 1
1 1 3
1 2 1 1
1 2 2
1 3 1
1 4
2 1 1 1
2 1 2
2 2 1
2 3
3 1 1
3 2
4 1
5
1 1 1 1
1 1 2
1 2 1
1 3
2 1 1
2 2
3 1
4
1 1 1
1 2
2 1
3
1 1
2
1

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1mitchs710.04012015/04/29 12:46:580B / 42B / 21B
2leonid720.05002014/11/12 09:17:360B / 35B / 34B

Ruby2 _

RankUserSizeTimeDateStatistics
1mitchs680.20772015/11/26 08:44:460B / 30B / 34B

Perl _

RankUserSizeTimeDateStatistics
1tails500.11282015/11/26 19:35:560B / 17B / 31B

Python _

RankUserSizeTimeDateStatistics
1mitchs760.14902014/12/19 16:37:220B / 36B / 36B
2leonid770.12342014/11/21 07:26:370B / 37B / 36B
3xsot830.14862017/05/02 20:17:200B / 40B / 39B
4whatisgolf870.08442014/11/13 21:32:000B / ?B / ?B
5twobit870.14142015/02/10 19:39:090B / ?B / ?B
6recursive910.09262014/12/30 02:45:570B / 48B / 32B
7xnor940.10192015/09/18 10:40:420B / ?B / ?B
8rolf1070.18152015/01/07 04:53:000B / 55B / 43B

Python3 _

RankUserSizeTimeDateStatistics
1mitchs830.21632015/04/29 12:10:590B / 43B / 37B
2recursive930.16142014/12/30 03:05:560B / 48B / 35B
3Stephan W.1120.16352015/07/06 21:17:030B / 61B / 35B

JavaScript _

RankUserSizeTimeDateStatistics
1FizzyTea860.26292015/04/30 21:55:330B / 47B / 38B

PARI/GP _

RankUserSizeTimeDateStatistics
1mitchs680.03362015/09/06 08:04:240B / 36B / 31B

C _

RankUserSizeTimeDateStatistics
1fzort980.03622014/12/02 08:30:000B / ?B / ?B
2llhuii1000.03182014/11/22 14:58:540B / 46B / 54B

C++ _

RankUserSizeTimeDateStatistics
1JackSparrow4760.02452016/02/04 17:37:100B / 189B / 97B

Haskell _

RankUserSizeTimeDateStatistics
1henkma840.03742014/11/13 21:35:110B / 50B / 31B
2yochi2850.04372014/11/16 19:31:060B / 46B / 33B
3oerjan860.02652014/11/13 12:37:460B / 49B / 32B

AWK _

RankUserSizeTimeDateStatistics
1mitchs530.03602014/11/20 02:35:440B / 28B / 24B

sed _

RankUserSizeTimeDateStatistics
1tails1080.20222015/01/23 12:05:480B / 26B / 72B

jq _

RankUserSizeTimeDateStatistics
1clock650.03382015/02/20 15:02:490B / 28B / 35B

xgawk _

RankUserSizeTimeDateStatistics
1mitchs490.03372014/11/20 02:34:290B / 24B / 24B
2llhuii620.03582014/11/20 22:53:400B / ?B / ?B

Brainfuck _

RankUserSizeTimeDateStatistics
1mitchs1240.05072014/11/18 18:26:520B / 0B / 124B

Whitespace _

RankUserSizeTimeDateStatistics
1mitchs2010.10762015/03/29 05:20:300B / 0B / 0B

GolfScript _

RankUserSizeTimeDateStatistics
1tails310.17332016/05/26 17:31:590B / 6B / 24B
2mitchs320.16082016/05/26 17:16:430B / 3B / 28B

gs2 _

RankUserSizeTimeDateStatistics
1mitchs190.30902015/04/30 15:07:597B / 8B / 4B

FlogScript _

RankUserSizeTimeDateStatistics
1mitchs300.22592015/05/03 08:34:460B / 4B / 26B

Language Ranking_

RankLangUserSizeScore
1gs2mitchs1910000
2FlogScriptmitchs306333
3GolfScripttails316129
4xgawkmitchs493877
5Perltails503800
6AWKmitchs533584
7jqclock652923
8PARI/GPmitchs682794
9Ruby2mitchs682794
10Rubymitchs712676
11Pythonmitchs762500
12Python3mitchs832289
13Haskellhenkma842261
14JavaScriptFizzyTea862209
15Cfzort981938
16sedtails1081759
17Brainfuckmitchs1241532
18Whitespacemitchs201945
19C++JackSparrow476399

return top