Enumerate Compositions
Submit
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
1 1 5 2
1 1 6 1
1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 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
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 71 | 0.0401 | 2015/04/29 12:46:58 | 0B / 42B / 21B |
2 | leonid | 72 | 0.0500 | 2014/11/12 09:17:36 | 0B / 35B / 34B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 68 | 0.2077 | 2015/11/26 08:44:46 | 0B / 30B / 34B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 50 | 0.1128 | 2015/11/26 19:35:56 | 0B / 17B / 31B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 76 | 0.1490 | 2014/12/19 16:37:22 | 0B / 36B / 36B |
2 | leonid | 77 | 0.1234 | 2014/11/21 07:26:37 | 0B / 37B / 36B |
3 | xnor | 80 | 0.1171 | 2022/09/06 17:07:26 | 0B / 42B / 34B |
4 | xsot | 81 | 0.1025 | 2017/11/19 14:46:26 | 0B / 41B / 35B |
5 | whatisgolf | 87 | 0.0844 | 2014/11/13 21:32:00 | 0B / ?B / ?B |
6 | twobit | 87 | 0.1414 | 2015/02/10 19:39:09 | 0B / ?B / ?B |
7 | recursive | 91 | 0.0926 | 2014/12/30 02:45:57 | 0B / 48B / 32B |
8 | rolf | 107 | 0.1815 | 2015/01/07 04:53:00 | 0B / 55B / 43B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | xnor | 75 | 0.1418 | 2022/09/06 18:03:05 | 0B / 38B / 31B |
2 | mitchs | 83 | 0.2163 | 2015/04/29 12:10:59 | 0B / 43B / 37B |
3 | xsot | 83 | 0.1545 | 2017/11/19 15:13:48 | 0B / 43B / 37B |
4 | recursive | 93 | 0.1614 | 2014/12/30 03:05:56 | 0B / 48B / 35B |
5 | Stephan W. | 112 | 0.1635 | 2015/07/06 21:17:03 | 0B / 61B / 35B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | FizzyTea | 86 | 0.2629 | 2015/04/30 21:55:33 | 0B / 47B / 38B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | clock | 106 | 0.0340 | 2019/04/19 22:27:45 | 0B / 62B / 35B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 68 | 0.0336 | 2015/09/06 08:04:24 | 0B / 36B / 31B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | fzort | 98 | 0.0362 | 2014/12/02 08:30:00 | 0B / ?B / ?B |
2 | llhuii | 100 | 0.0318 | 2014/11/22 14:58:54 | 0B / 46B / 54B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | JackSparrow | 476 | 0.0245 | 2016/02/04 17:37:10 | 0B / 189B / 97B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | henkma | 84 | 0.0374 | 2014/11/13 21:35:11 | 0B / 50B / 31B |
2 | yochi2 | 85 | 0.0437 | 2014/11/16 19:31:06 | 0B / 46B / 33B |
3 | oerjan | 86 | 0.0265 | 2014/11/13 12:37:46 | 0B / 49B / 32B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | rotary-o | 165 | 0.2095 | 2022/09/11 01:40:33 | 0B / 95B / 62B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 53 | 0.0360 | 2014/11/20 02:35:44 | 0B / 28B / 24B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 96 | 0.2036 | 2019/12/11 20:00:59 | 0B / 27B / 60B |
2 | mitchs | 97 | 0.1765 | 2019/12/12 01:15:15 | 0B / 35B / 50B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | clock | 65 | 0.0338 | 2015/02/20 15:02:49 | 0B / 28B / 35B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | McBusLuck | 4772 | 0.0206 | 2020/08/06 04:49:51 | 0B / 2377B / 82B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 49 | 0.0337 | 2014/11/20 02:34:29 | 0B / 24B / 24B |
2 | llhuii | 62 | 0.0358 | 2014/11/20 22:53:40 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 124 | 0.0507 | 2014/11/18 18:26:52 | 0B / 0B / 124B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 201 | 0.1076 | 2015/03/29 05:20:30 | 0B / 0B / 0B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 31 | 0.1733 | 2016/05/26 17:31:59 | 0B / 6B / 24B |
2 | mitchs | 32 | 0.1608 | 2016/05/26 17:16:43 | 0B / 3B / 28B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 19 | 0.3090 | 2015/04/30 15:07:59 | 7B / 8B / 4B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 14 | 0.0413 | 2022/02/15 20:07:56 | 9B / 1B / 4B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | mitchs | 30 | 0.2259 | 2015/05/03 08:34:46 | 0B / 4B / 26B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 802 | 0.0850 | 2020/01/28 12:51:47 | 0B / 439B / 363B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 56 | 0.4922 | 2024/02/28 15:07:08 | 36B / 14B / 3B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | rotary-o | 90 | 6.7803 | 2022/09/11 01:13:31 | 0B / 53B / 31B |
2 | clock | 102 | 6.4013 | 2019/12/09 19:57:45 | 0B / 59B / 38B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | user202729 | 104 | 0.0492 | 2017/09/30 14:27:40 | 0B / ?B / ?B |
Language Ranking_
Rank | Lang | User | Size | Score |
1 | Nibbles | tails | 14 | 10000 |
2 | gs2 | mitchs | 19 | 7368 |
3 | FlogScript | mitchs | 30 | 4666 |
4 | GolfScript | tails | 31 | 4516 |
5 | xgawk | mitchs | 49 | 2857 |
6 | Perl | tails | 50 | 2800 |
7 | AWK | mitchs | 53 | 2641 |
8 | Universal Lambda | tails | 56 | 2500 |
9 | jq | clock | 65 | 2153 |
10 | PARI/GP | mitchs | 68 | 2058 |
11 | Ruby2 | mitchs | 68 | 2058 |
12 | Ruby | mitchs | 71 | 1971 |
13 | Python3 | xnor | 75 | 1866 |
14 | Python | mitchs | 76 | 1842 |
15 | Haskell | henkma | 84 | 1666 |
16 | JavaScript | FizzyTea | 86 | 1627 |
17 | Scala | rotary-o | 90 | 1555 |
18 | sed | tails | 96 | 1458 |
19 | C | fzort | 98 | 1428 |
20 | Logo | user202729 | 104 | 1346 |
21 | Lua | clock | 106 | 1320 |
22 | Brainfuck | mitchs | 124 | 1129 |
23 | Java | rotary-o | 165 | 848 |
24 | Whitespace | mitchs | 201 | 696 |
25 | C++ | JackSparrow | 476 | 294 |
26 | Lazy-K | tails | 802 | 174 |
27 | bc | McBusLuck | 4772 | 29 |
return to the top page