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
3xnor800.11712022/09/06 17:07:260B / 42B / 34B
4xsot810.10252017/11/19 14:46:260B / 41B / 35B
5whatisgolf870.08442014/11/13 21:32:000B / ?B / ?B
6twobit870.14142015/02/10 19:39:090B / ?B / ?B
7recursive910.09262014/12/30 02:45:570B / 48B / 32B
8rolf1070.18152015/01/07 04:53:000B / 55B / 43B

Python3 _

RankUserSizeTimeDateStatistics
1xnor750.14182022/09/06 18:03:050B / 38B / 31B
2mitchs830.21632015/04/29 12:10:590B / 43B / 37B
3xsot830.15452017/11/19 15:13:480B / 43B / 37B
4recursive930.16142014/12/30 03:05:560B / 48B / 35B
5Stephan W.1120.16352015/07/06 21:17:030B / 61B / 35B

JavaScript _

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

Lua _

RankUserSizeTimeDateStatistics
1clock1060.03402019/04/19 22:27:450B / 62B / 35B

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

Java _

RankUserSizeTimeDateStatistics
1rotary-o1650.20952022/09/11 01:40:330B / 95B / 62B

AWK _

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

sed _

RankUserSizeTimeDateStatistics
1tails960.20362019/12/11 20:00:590B / 27B / 60B
2mitchs970.17652019/12/12 01:15:150B / 35B / 50B

jq _

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

bc _

RankUserSizeTimeDateStatistics
1McBusLuck47720.02062020/08/06 04:49:510B / 2377B / 82B

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

Nibbles _

RankUserSizeTimeDateStatistics
1tails140.04132022/02/15 20:07:569B / 1B / 4B

FlogScript _

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

Lazy-K _

RankUserSizeTimeDateStatistics
1tails8020.08502020/01/28 12:51:470B / 439B / 363B

Universal Lambda _

RankUserSizeTimeDateStatistics
1tails560.49222024/02/28 15:07:0836B / 14B / 3B

Scala _

RankUserSizeTimeDateStatistics
1rotary-o906.78032022/09/11 01:13:310B / 53B / 31B
2clock1026.40132019/12/09 19:57:450B / 59B / 38B

Logo _

RankUserSizeTimeDateStatistics
1user2027291040.04922017/09/30 14:27:400B / ?B / ?B

Language Ranking_

RankLangUserSizeScore
1Nibblestails1410000
2gs2mitchs197368
3FlogScriptmitchs304666
4GolfScripttails314516
5xgawkmitchs492857
6Perltails502800
7AWKmitchs532641
8Universal Lambdatails562500
9jqclock652153
10PARI/GPmitchs682058
11Ruby2mitchs682058
12Rubymitchs711971
13Python3xnor751866
14Pythonmitchs761842
15Haskellhenkma841666
16JavaScriptFizzyTea861627
17Scalarotary-o901555
18sedtails961458
19Cfzort981428
20Logouser2027291041346
21Luaclock1061320
22Brainfuckmitchs1241129
23Javarotary-o165848
24Whitespacemitchs201696
25C++JackSparrow476294
26Lazy-Ktails802174
27bcMcBusLuck477229

return to the top page