infix to postfix

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

Convert lines from infix notation to postfix (reverse polish notation). Variables must remain in same order and precedence must be preserved.

Examples:
a+b -> ab+
a+b+c -> ab+c+ (not abc++ because would evaluate b+c first)
a-b*c -> abc*- (because * is higher precedence than -)
(a-b)*c -> ab-c* (because of ())

Options

exec is denied

no deadline, the server will not save your submission

Sample input:_

a+b+c*d
a*b*(c+d)+e

Sample output:

ab+cd*+
ab*cd+*e+

Sample input:_

k/r/(v*((g/(o*p*d/q*(((l+(z*n)-(h/y*w)-j+x)+(i)*a)*c+s)/m))/b)/u-e-f)
u*g*i*d/b*h/((z*(e*l-c)+w)*q-(a)/v)*f
a/n/e*(d*(y/b*p*(k/s/w/((m/(v/j/i)*t))))-q/g)/c*r
(a/(((l*((((f*b*r*h))*n/q)-(s/o-(v)*c*t))*x)+d)/i/j))
(((i/((m/(y*q*o/g/w/r-k)+u*n)+b*((x/f*((l-(a/e))/j))))))*t*d-c*h)
k/(t/x/((e/j*a/d*r*m-i)*n*f-q*(h-v*c*(l+o))*g)+u*s*p)
f/((t*(v/j*(c*y/(g/(l-(m*(z*i*(q*d*x)))/o)-n-p-b)/e))+k)+u*w-h*a)
((i*n*p/v/j*x/(u*b*(q-r/(h/t/a/(l+(c+(e/f))-k)/z))+y/o-d/s)-g))-m
d*((((z/f/r*(p*l/(e-m*((i/w*h)*k/(x/c+g))+(o)-n)))/j)))/b
(b/p*((((t*(v/a*y/((e*j/m)-(s/z-r+(h-(n))))*u/i)+d)))))
a/d*v*l/(e/y/x*(q/z-s)/p/j)
b/a/(v/(w*g/i*q/j*(((l-c)))-(d/(y/(m)*f)+o+p)*s))/(x)-r

Sample output:

kr/vgop*d*q/lzn*+hy/w*-j-x+ia*+c*s+*m//b/*u/e-f-/
ug*i*d*b/h*zel*c-*w+q*av/-/f*
an/e/dyb/p*ks/w/mvj/i//t*/**qg/-*c/r*
alfb*r*h*n*q/so/v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dx/m/b*q*n*u/r/wy/ok+zc/p*+f/-ea/-/
gh*kf*v/zt*l*yx*s/o*imq/aw*uc*d**+/*p/j*-*/r-
mn*w*oua/q*d+f+/ph*r*-ci*+*k/b+s+
jxh/za*p*f*t*ou/q**wi*r*c*b//*e//d-
yj*u/kwng*d*vo/q/*rhs/f/z*-*tm*+*/e//
wn/vqa/f/j/xt*b*yl/p/k*d-u+e/*m/g*+/or*i/c//s-*h/z-
jzc*p*i*ox/hg*t/ae/b/ny-*--*l*k*s+v+d*w*/
yuv*hb*e*i/j*/f**k*g*
uo*ry/e*ps*h/b*j-*d*lf/+*i-

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1flagitious590.11292007/12/26 04:57:130B / ?B / ?B
2kinaba590.10582008/01/06 15:30:380B / 35B / 18B
3leonid590.07222012/02/26 00:30:030B / 35B / 17B
4@tttttanaka610.08302012/03/25 07:48:050B / 39B / 20B
5%20(shinh)610.04602016/08/02 04:35:190B / 37B / 20B
6jacknero630.09402008/07/31 15:41:012B / ?B / ?B
7shinh1051.71182007/03/02 05:10:060B / 14B / 86B
8flagitious(alnum)1380.17872008/09/30 14:29:110B / 123B / 0B
9niha2520.35752007/02/28 02:13:460B / 107B / 132B

Perl _

RankUserSizeTimeDateStatistics
1tails520.04922017/02/22 09:55:100B / 14B / 38B
2tybalt89720.01222010/08/12 00:22:470B / ?B / ?B
3ySas1020.40162008/01/22 16:10:040B / 27B / 73B
4ySas(inspired by kinaba)1120.56362007/03/02 00:09:050B / 55B / 55B

Python _

RankUserSizeTimeDateStatistics
1llhuii1320.10892014/03/14 15:49:510B / 59B / 57B
2hallvabo1330.39292013/12/11 08:18:240B / 83B / 41B
3xsot1360.81052017/02/24 22:07:380B / 65B / 63B
4twobit1420.20782012/06/02 20:00:240B / 83B / 52B
5mitchs (no import)1430.09072014/02/27 13:13:250B / 59B / 67B
6xsot (no import)1430.16862017/02/19 18:58:250B / 59B / 71B
7twobit (no import)1550.06542012/06/08 00:09:090B / 78B / 61B
8hallvabo (no import)1690.07002011/10/26 07:49:570B / 73B / 74B
9SeeNoEvil1880.36222007/03/30 18:56:590B / 84B / 75B
10rolf2550.05402013/01/03 05:16:320B / 119B / 104B
11zetamatta2690.12072008/01/06 04:10:200B / 142B / 89B

PHP _

RankUserSizeTimeDateStatistics
1primo1950.15022012/01/18 23:53:365B / 80B / 109B

Scheme _

RankUserSizeTimeDateStatistics
1ma2360.67312007/03/02 15:04:340B / ?B / ?B

Common LISP _

RankUserSizeTimeDateStatistics
1kozima2380.55452008/01/07 14:25:580B / 110B / 114B

JavaScript _

RankUserSizeTimeDateStatistics
1FizzyTea1650.05612016/05/23 15:56:340B / 68B / 97B
2nn1760.20982008/10/18 23:34:560B / ?B / ?B
3nn(1.9)1790.01712010/03/16 22:11:310B / 56B / 120B
4murky-satyr1870.15482008/05/24 02:02:490B / 77B / 107B

Smalltalk _

RankUserSizeTimeDateStatistics
1murky-satyr2930.71482008/04/10 22:12:110B / 158B / 122B

Prolog _

RankUserSizeTimeDateStatistics
1mskzzzz2610.40792007/05/10 21:29:480B / 129B / 126B

J _

RankUserSizeTimeDateStatistics
1I., S.(RegExp)1940.96822010/11/23 19:31:420B / 45B / 147B
2I., S.2101.03432010/11/23 08:12:500B / 53B / 151B

C _

RankUserSizeTimeDateStatistics
1nai930.03352013/05/25 09:59:320B / 51B / 42B
2tails990.03202017/02/22 15:27:244B / 45B / 50B
3flagitious1050.06422008/01/05 04:45:310B / 60B / 45B
4hinoe1250.18292007/06/24 16:01:490B / 65B / 60B
5ozy4dm1330.08462007/03/29 10:48:170B / 69B / 64B
67gyou1330.04882008/01/13 05:36:280B / 66B / 67B
751b1540.05942008/01/26 17:47:590B / 65B / 89B
8kinaba1720.07472007/03/03 11:07:050B / ?B / ?B
9RiSK2180.06592007/02/28 15:32:160B / 112B / 103B

D _

RankUserSizeTimeDateStatistics
151b1900.08572009/09/21 21:51:590B / 108B / 78B

OCaml _

RankUserSizeTimeDateStatistics
1ksk2390.40262007/03/06 17:09:230B / 131B / 85B
2suiginto2760.36822007/03/04 21:49:370B / 142B / 109B
3m.ukai4481.07792007/03/02 19:27:200B / 219B / 174B

Haskell _

RankUserSizeTimeDateStatistics
1rst761660.00202010/01/20 11:36:050B / 79B / 69B
2Magnus Jonsson1860.10472007/04/26 09:47:320B / 85B / 95B
3tanakh1910.10162007/03/07 11:42:000B / ?B / ?B
4emoken2030.10042007/03/04 06:06:010B / ?B / ?B
5_2080.12122007/03/02 11:55:280B / 73B / 121B

Ada _

RankUserSizeTimeDateStatistics
1D3460.18392007/04/10 18:46:460B / 218B / 102B

Java _

RankUserSizeTimeDateStatistics
1nattow4861.20202007/04/03 10:31:140B / 234B / 236B

AWK _

RankUserSizeTimeDateStatistics
1llhuii1350.03372014/03/19 00:38:310B / 65B / 68B
2nn1980.04182008/10/19 20:23:300B / 61B / 133B

sed _

RankUserSizeTimeDateStatistics
1tails760.04232017/02/23 19:42:350B / 9B / 61B
2I., S.1690.03012011/08/15 09:33:300B / 32B / 126B
3emoken2690.38622007/03/11 00:33:510B / 43B / 199B

wake _

RankUserSizeTimeDateStatistics
1tails570.09392017/03/01 16:53:390B / 5B / 49B
2emoken1310.03122010/07/24 14:31:560B / 18B / 107B

xgawk _

RankUserSizeTimeDateStatistics
1llhuii1350.03422014/03/17 23:13:180B / 65B / 68B

Postscript _

RankUserSizeTimeDateStatistics
1ySas1310.57492008/01/07 14:14:4644B / 35B / 50B
2yshl(bin)1420.49492008/01/08 15:40:3754B / 44B / 42B
3yshl2040.60812008/01/08 15:40:220B / 128B / 42B

Brainfuck _

RankUserSizeTimeDateStatistics
1mitchs2220.08992016/08/02 14:07:520B / 0B / 222B

Whitespace _

RankUserSizeTimeDateStatistics
1flagitious2560.39682008/01/04 13:38:380B / 0B / 0B

Befunge _

RankUserSizeTimeDateStatistics
1flagitious861.08512008/01/04 14:53:330B / 36B / 40B

Aheui _

RankUserSizeTimeDateStatistics
1Rexion_ize3320.03912015/02/21 17:13:38324B / ?B / ?B

GolfScript _

RankUserSizeTimeDateStatistics
1tails570.14022017/02/28 16:33:260B / 10B / 47B
2flagitious661.94862008/01/04 08:46:490B / 20B / 46B

gs2 _

RankUserSizeTimeDateStatistics
1tails380.34772017/03/01 14:20:5717B / 18B / 1B

Unlambda _

RankUserSizeTimeDateStatistics
1irori7040.02092007/04/01 22:08:240B / 337B / 367B

z80 _

RankUserSizeTimeDateStatistics
1kodera441.13422008/01/07 01:54:3526B / 8B / 8B

Vim _

RankUserSizeTimeDateStatistics
1clock1150.80542012/01/08 21:32:143B / 33B / 69B

goruby _

RankUserSizeTimeDateStatistics
1shinh400.21352008/01/09 03:17:530B / 18B / 18B
2flagitious540.13542008/01/09 02:03:330B / 37B / 10B
3kinaba600.14262008/01/08 17:48:410B / 35B / 19B
4flagitious(alnum)620.10842008/01/09 04:06:520B / 51B / 1B
5shinh(alnum)620.15472008/01/09 04:31:230B / 51B / 1B

Groovy _

RankUserSizeTimeDateStatistics
1murky-satyr1553.63342009/12/16 07:51:160B / 67B / 83B

Scala _

RankUserSizeTimeDateStatistics
1tarhashi39514.89452012/06/20 15:47:420B / ?B / ?B

Language Ranking_

RankLangUserSizeScore
1gs2tails3810000
2gorubyshinh409500
3z80kodera448636
4Perltails527307
5GolfScripttails576666
6waketails576666
7Rubyflagitious596440
8sedtails765000
9Befungeflagitious864418
10Cnai934086
11Vimclock1153304
12PostscriptySas1312900
13Pythonllhuii1322878
14xgawkllhuii1352814
15AWKllhuii1352814
16Groovymurky-satyr1552451
17JavaScriptFizzyTea1652303
18Haskellrst761662289
19D51b1902000
20JI., S.(RegExp)1941958
21PHPprimo1951948
22Brainfuckmitchs2221711
23Schemema2361610
24Common LISPkozima2381596
25OCamlksk2391589
26Whitespaceflagitious2561484
27Prologmskzzzz2611455
28Smalltalkmurky-satyr2931296
29AheuiRexion_ize3321144
30AdaD3461098
31Scalatarhashi395962
32Javanattow486781
33Unlambdairori704539

Referer

Note that, they may contain spoilers.

return top