Expression

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 sequence of integers, generate all expressions that can be
made from the integers, subtraction (-), and parentheses, without
changing the order of integers. Calculate the expressions and
print the values in ascending order, removing duplicates.

For example, if the sequence is "1, 2, 3", then possible expressions are:
(1-2)-3
1-(2-3)
plus those with redundant parentheses. And the output should be:
-4
2

Options

exec is denied

no deadline, the server will not save your submission

Sample input:_

1 1 1 1 1

Sample output:

-3
-1
1
3

Sample input:_

1 1 2 3 5 8 13

Sample output:

-31
-27
-25
-21
-17
-15
-11
-9
-5
-1
1
5
9
11
15
17
21
25
27
31

Sample input:_

1 3 8 12 6 4 3 2 7

Sample output:

-44
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
40

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1leonid702.01212011/03/08 03:26:210B / 32B / 35B
2fsystem790.73232007/12/01 12:12:080B / ?B / ?B
3shinh840.36402007/02/13 05:54:00?B / ?B / ?B
4flagitious870.07822007/09/23 00:26:030B / 43B / 39B
5kinaba960.32012007/02/12 23:19:16?B / ?B / ?B
6hrkw1110.70172007/02/12 19:52:28?B / ?B / ?B
7tabasa3040.25262007/10/11 12:05:4722B / 125B / 113B

Perl _

RankUserSizeTimeDateStatistics
1tails590.04942016/08/22 10:13:020B / 27B / 30B
2tybalt89600.11632010/08/18 06:09:210B / ?B / ?B
3ySas650.15962008/01/31 15:36:160B / 25B / 37B
4shinh920.35392007/02/13 05:35:32?B / ?B / ?B
5BioFALSE1540.03482013/01/27 23:49:373B / 56B / 85B

Python _

RankUserSizeTimeDateStatistics
1leonid780.09392013/12/12 23:09:260B / 45B / 28B
2hallvabo990.06842010/10/20 17:26:090B / 43B / 51B
3recursive1080.06222010/03/31 01:17:450B / 67B / 37B
4rolf1340.34472013/10/05 06:44:520B / 78B / 45B
5z1360.05652010/04/03 06:57:170B / 87B / 39B
6hallvabo (noembed)1430.19072015/09/20 06:23:500B / 81B / 56B
7mskzzzz1560.51852007/06/16 01:31:170B / 96B / 43B
8SeeNoEvil1751.26922007/03/25 07:48:470B / 98B / 60B
98080.99002007/03/25 01:19:440B / ?B / ?B

Python3 _

RankUserSizeTimeDateStatistics
1mypetlion1210.12412019/05/23 07:49:190B / 69B / 40B

PHP _

RankUserSizeTimeDateStatistics
1o-cn1100.08532010/01/12 05:57:062B / 49B / 59B
2mskzzzz2360.65372007/06/16 01:47:520B / 132B / 99B

Scheme _

RankUserSizeTimeDateStatistics
1ma1300.42662007/03/06 22:00:290B / ?B / ?B

Common LISP _

RankUserSizeTimeDateStatistics
1kozima(embed)1480.35572007/05/22 13:30:015B / 77B / 62B
2kozima1890.53322007/03/26 14:06:160B / 96B / 80B

Arc _

RankUserSizeTimeDateStatistics
1murky-satyr9912.17992009/10/31 02:23:210B / 51B / 36B

Io _

RankUserSizeTimeDateStatistics
1murky-satyr1852.47252008/03/09 03:30:080B / 115B / 56B
2poop2053.76022007/08/27 23:07:350B / 129B / 46B

JavaScript _

RankUserSizeTimeDateStatistics
1xulapp1040.04402010/03/29 03:43:320B / 58B / 45B
2nn1160.03892010/03/28 15:59:360B / 54B / 61B
3Dashiva1550.12202007/04/21 00:38:550B / 82B / 67B
4murky-satyr1570.03902008/06/17 00:55:290B / 80B / 73B
5mskzzzz2650.89912007/06/20 03:41:030B / 151B / 103B

Lua _

RankUserSizeTimeDateStatistics
1tehtmi1520.03222019/03/26 18:17:400B / 92B / 45B
2pooq1900.07442008/11/23 01:59:430B / 110B / 45B

Smalltalk _

RankUserSizeTimeDateStatistics
1murky-satyr1840.64802008/07/13 12:00:470B / 119B / 52B
2sumim2361.22912007/02/17 01:29:590B / 140B / 80B

Prolog _

RankUserSizeTimeDateStatistics
1mskzzzz1590.40732007/05/28 22:21:530B / 95B / 57B

BASIC _

RankUserSizeTimeDateStatistics
1poop1760.16412007/08/27 21:53:060B / 99B / 42B

Erlang _

RankUserSizeTimeDateStatistics
151b2041.05112008/01/13 11:23:470B / 85B / 114B
2jijixi3852.05882007/02/22 20:02:190B / 214B / 160B
3mskzzzz5141.93232007/06/02 18:32:540B / 273B / 229B

J _

RankUserSizeTimeDateStatistics
1I., S.470.12002010/12/17 22:14:090B / 12B / 35B
2poop890.26482008/06/17 17:39:380B / 35B / 54B

C _

RankUserSizeTimeDateStatistics
1tails1020.03292019/03/27 09:41:040B / 50B / 50B
2hinoe1360.09802007/05/01 06:23:260B / 53B / 83B
37gyou1400.06452008/02/02 01:29:540B / 66B / 74B
451b1460.05212008/01/13 12:33:080B / 68B / 78B

D _

RankUserSizeTimeDateStatistics
151b1510.07522008/01/13 12:30:420B / 93B / 54B

OCaml _

RankUserSizeTimeDateStatistics
1ksk(embed)1600.92792007/03/11 23:35:090B / 100B / 56B
2m.ukai(embed)2750.28162007/03/06 19:35:540B / 144B / 63B
3jijixi3130.31262007/02/17 23:06:350B / 189B / 99B

Haskell _

RankUserSizeTimeDateStatistics
1notogawa1020.08842007/08/19 12:48:040B / ?B / ?B
2henkma1020.00502011/09/02 08:09:420B / 69B / 26B
3tanakh1030.11792007/02/15 18:34:470B / 68B / 28B
4Lost_dog1030.00412010/08/06 17:54:590B / 67B / 29B
5aljee1040.11082007/02/24 17:12:180B / ?B / ?B
6oxy1090.08012007/02/14 13:04:01?B / ?B / ?B
7_1100.12782007/02/13 00:02:07?B / ?B / ?B
8kinaba1140.08772007/02/12 23:32:25?B / ?B / ?B

Pascal _

RankUserSizeTimeDateStatistics
1uru2720.01082009/07/01 21:45:270B / 153B / 54B

Asymptote _

RankUserSizeTimeDateStatistics
1xulapp1341.50252010/04/18 09:11:490B / 77B / 56B
2pooq2103.18662009/04/18 12:57:500B / 119B / 66B

AWK _

RankUserSizeTimeDateStatistics
1nn1100.00652009/11/30 00:42:470B / 49B / 58B
2eban1220.08082007/02/12 22:39:36?B / ?B / ?B

sed _

RankUserSizeTimeDateStatistics
1eban2230.09102007/02/12 18:17:29?B / ?B / ?B

Bash _

RankUserSizeTimeDateStatistics
1yamaya580.23322010/03/20 00:23:060B / 29B / 22B

Bash (builtins) _

RankUserSizeTimeDateStatistics
1tails770.03492017/10/06 16:34:060B / 26B / 42B

Postscript _

RankUserSizeTimeDateStatistics
1ySas780.92742007/07/09 21:00:5232B / 27B / 18B
2yshl(bin)870.62142008/01/13 12:07:3629B / 33B / 23B
3yshl1490.58362008/01/13 12:07:210B / 107B / 18B

R _

RankUserSizeTimeDateStatistics
1NikNakk1040.54562014/07/05 08:03:310B / ?B / ?B
2poop1313.92922008/06/17 22:23:530B / 68B / 62B

Befunge _

RankUserSizeTimeDateStatistics
1ySas1180.88772007/02/28 17:12:220B / 32B / 72B

GolfScript _

RankUserSizeTimeDateStatistics
1tails300.06222016/08/22 11:49:480B / 2B / 28B
2flagitious340.24472007/12/15 12:26:210B / 6B / 28B

gs2 _

RankUserSizeTimeDateStatistics
1tails170.33672019/03/27 09:51:187B / 4B / 4B

Universal Lambda _

RankUserSizeTimeDateStatistics
1hinoe3011.31492009/03/15 13:22:30227B / 45B / 25B

z80 _

RankUserSizeTimeDateStatistics
1ySas930.85792008/01/04 00:28:5153B / 20B / 14B

Vim _

RankUserSizeTimeDateStatistics
1clock930.14272012/01/07 02:40:428B / 30B / 49B
2nn1580.07552009/12/23 11:41:282B / 85B / 57B

goruby _

RankUserSizeTimeDateStatistics
1leonid512.31102010/11/27 02:41:210B / 19B / 29B
2murky-satyr660.47652008/10/26 20:48:350B / 30B / 31B

Groovy _

RankUserSizeTimeDateStatistics
1nn1083.52822009/12/26 21:31:140B / 64B / 40B
2murky-satyr1093.58472009/12/26 20:35:120B / 60B / 45B

Scala _

RankUserSizeTimeDateStatistics
1rotary-o1188.97512020/01/03 17:47:560B / 71B / 41B
2clock1188.77662020/01/03 20:01:000B / 71B / 41B
3murky-satyr12312.51552012/06/18 12:22:100B / 80B / 35B
4tarhashi14615.44882012/06/12 13:06:580B / ?B / ?B

Language Ranking_

RankLangUserSizeScore
1gs2tails1710000
2GolfScripttails305666
3JI., S.473617
4gorubyleonid513333
5Bashyamaya582931
6Perltails592881
7Rubyleonid702428
8Bash (builtins)tails772207
9PostscriptySas782179
10Pythonleonid782179
11z80ySas931827
12Vimclock931827
13Arcmurky-satyr991717
14Haskellnotogawa1021666
15Ctails1021666
16JavaScriptxulapp1041634
17RNikNakk1041634
18Groovynn1081574
19AWKnn1101545
20PHPo-cn1101545
21BefungeySas1181440
22Scalarotary-o1181440
23Python3mypetlion1211404
24Schemema1301307
25Asymptotexulapp1341268
26Common LISPkozima(embed)1481148
27D51b1511125
28Luatehtmi1521118
29Prologmskzzzz1591069
30OCamlksk(embed)1601062
31BASICpoop176965
32Smalltalkmurky-satyr184923
33Iomurky-satyr185918
34Erlang51b204833
35sedeban223762
36Pascaluru272625
37Universal Lambdahinoe301564

Referer

Note that, they may contain spoilers.

return to the top page