prefix 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 prefix (Polish) notation to postfix (Reverse Polish) notation.

http://en.wikipedia.org/wiki/Polish_notation
http://en.wikipedia.org/wiki/Reverse_Polish_notation

--nooodl

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

/ 7 2
^ / 7 1 4
+ 6 + 1 8
* + 1 9 3
- - / 2 - 4 4 2 5
^ ^ 1 / 9 9 / * ^ 6 6 - 1 * 8 6 + 4 + 5 + 5 7
/ 4 7
- 9 / + ^ + 8 9 5 5 1
- / + * + 5 4 / 2 3 + / * 8 2 1 3 4 5
* * 1 + 1 6 - * / * 2 * 6 4 1 5 - - 2 1 - 6 3

Sample output:

7 2 /
7 1 / 4 ^
6 1 8 + +
1 9 + 3 *
2 4 4 - / 2 - 5 -
1 9 9 / ^ 6 6 ^ 1 8 6 * - * 4 5 5 7 + + + / ^
4 7 /
9 8 9 + 5 ^ 5 + 1 / -
5 4 + 2 3 / * 8 2 * 1 / 3 + + 4 / 5 -
1 1 6 + * 2 6 4 * * 1 / 5 * 2 1 - 6 3 - - - *

Sample input:_

* / ^ 3 6 - 2 4 - / 2 3 ^ ^ 4 4 ^ 5 6
/ 1 5
/ 9 2
- - / 5 + 5 * / 7 2 6 * * 4 4 + * 1 9 * 1 3 7
+ ^ / + 1 3 6 3 * 4 3
^ ^ + 9 9 4 - * 3 + / 9 3 4 4
+ 3 6
/ / + 1 7 5 / 9 4
+ * 7 / 9 1 5
+ * 1 2 + 7 2
/ 8 / 3 1
+ 3 / 5 7
* - ^ 5 5 5 * - 3 / - 4 7 3 - / ^ + 9 - 4 9 9 / 5 5 8
/ * 7 * 5 3 - ^ 7 ^ 9 * / 3 ^ 8 2 2 ^ 2 ^ 7 / 7 8
/ 1 3
- - 4 1 - / 5 - 4 5 6
* / - 3 / 8 6 / / 6 ^ 5 4 ^ 4 5 - 6 6
+ 7 - * * 3 4 + 8 9 4
^ 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9 + 8 1 - * 3 5 * * / 4 3 * * / 7 * 4 4 - 7 1 8 / 3 4 + ^ 4 + ^ 1 ^ + - 8 5 3 4 * / + 5 3 + 8 3 / + / * + 4 * / - 2 - 7 * 3 2 / 7 9 8 + 3 * 7 8 * 4 + 5 6 3 / 2 5 ^ * + 7 / / 8 7 * 3 4 1 2 + 4 ^ / 3 / * * / 3 / / 4 - 6 6 7 * / 3 * 1 4 4 ^ * - 3 + ^ 5 7 5 ^ ^ 2 4 / / 7 2 - 9 + 8 * 7 * 2 * 8 9 + 8 6 6 + 4 + - + ^ 5 * 8 1 3 7 2 4 - 8 6 8

Sample output:

1 9 1 * 2 * 9 2 ^ * 9 / 9 3 1 6 ^ - 1 7 * + 4 5 5 ^ 5 3 + 7 + / 4 - 5 * / 7 + ^ 5 9 - - ^ 5 - 9 5 / + 8 7 - / ^ 8 8 7 - ^ - 9 - / 4 9 9 8 1 + / 3 5 * 4 3 / 7 4 4 * / 7 1 - * 8 * * 3 4 / * - + 4 1 8 5 - 3 + 4 ^ ^ 5 3 + 8 3 + / 4 2 7 3 2 * - - 7 9 / / 8 * + 3 7 8 * + * 4 5 6 + * / 3 + 2 5 / / * + ^ 7 8 7 / 3 4 * / + 1 * 2 ^ + - 4 3 3 4 6 6 - / 7 / / 3 1 4 * / 4 * * 3 5 7 ^ 5 + - 2 4 ^ 7 2 / 9 8 7 2 8 9 * * * + - / ^ * 8 6 + ^ * 6 / / 4 5 8 1 * ^ 3 + 7 - 2 + + ^ + - ^ 4 - 8 6 - + * 8 * -

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1leonid620.06392011/11/12 23:43:010B / ?B / ?B
2clock650.06162011/11/11 11:23:400B / 24B / 34B
3yvl670.09842011/11/02 23:06:210B / 29B / 30B
4test670.05852011/11/10 17:43:130B / 26B / 33B

Perl _

RankUserSizeTimeDateStatistics
1tails520.05002011/10/31 23:20:230B / 17B / 30B
2teebee540.05412011/11/01 00:10:300B / 18B / 31B
3ais523540.05332011/11/03 22:59:580B / ?B / ?B
4BioFALSE740.03682014/01/04 20:59:330B / 25B / 42B
5BioFALSE (regex)1660.03752014/01/04 20:08:520B / 61B / 85B
6BioFALSE (arr)2100.02692014/01/04 20:08:010B / 95B / 100B

Python _

RankUserSizeTimeDateStatistics
1leonid940.06472011/11/13 01:05:360B / 45B / 37B
2hallvabo980.10782011/11/13 23:25:150B / 48B / 38B
3twobit990.06302011/11/02 04:37:360B / 51B / 40B
4niisaka1190.21472011/11/14 05:39:100B / 71B / 43B
5leonid930.06422011/11/14 20:27:140B / 45B / 37B

PHP _

RankUserSizeTimeDateStatistics
1clock1101.15942011/11/13 01:13:589B / 44B / 55B

Scheme _

RankUserSizeTimeDateStatistics
1kaki720.09672011/11/14 05:21:470B / 33B / 34B
2youz720.10802011/11/14 09:58:260B / 34B / 33B

Common LISP _

RankUserSizeTimeDateStatistics
1youz870.33712011/10/31 13:02:240B / 39B / 43B

Arc _

RankUserSizeTimeDateStatistics
1youz662.98302011/10/31 16:39:320B / 28B / 32B

JavaScript _

RankUserSizeTimeDateStatistics
1nn850.07632011/11/08 00:34:150B / 39B / 43B
2xulapp (nn)820.05412011/11/15 00:37:190B / 40B / 42B

J _

RankUserSizeTimeDateStatistics
1I., S.560.09002011/11/02 05:39:420B / 19B / 37B

C _

RankUserSizeTimeDateStatistics
1nn640.32512011/11/12 12:52:560B / 31B / 33B
2hinoe650.04192011/11/11 23:57:100B / 37B / 28B
3inaniwa5010.04192011/11/11 21:28:5423B / 190B / 152B

C++ _

RankUserSizeTimeDateStatistics
1nn950.33122011/11/12 13:05:140B / 50B / 42B

Haskell _

RankUserSizeTimeDateStatistics
1koyama41850.08292011/11/13 14:30:130B / 50B / 33B
2rst76850.05282011/11/13 23:57:180B / 50B / 33B

sed _

RankUserSizeTimeDateStatistics
1nn500.04722011/11/01 09:55:470B / 12B / 32B
2clock500.05072011/11/11 12:27:560B / 12B / 32B
3clock480.05092011/11/14 11:08:010B / 10B / 32B

GolfScript _

RankUserSizeTimeDateStatistics
1tails360.14802011/11/11 21:26:140B / 7B / 28B

Vim _

RankUserSizeTimeDateStatistics
1nn340.31732011/11/14 02:03:542B / 19B / 10B
2clock410.43102011/11/14 00:06:280B / 21B / 15B
3clock(nn)310.33602011/11/14 14:29:582B / 15B / 11B
4nn330.32612011/11/14 14:23:262B / 19B / 9B

Groovy _

RankUserSizeTimeDateStatistics
1nn793.65802011/11/04 18:49:380B / 40B / 38B

Language Ranking_

RankLangUserSizeScore
1Vimclock(nn)3110000
2GolfScripttails368611
3sedclock486458
4Perltails525961
5JI., S.565535
6Rubyleonid625000
7Cnn644843
8Arcyouz664696
9Schemekaki724305
10Groovynn793924
11JavaScriptxulapp (nn)823780
12Haskellkoyama41853647
13Common LISPyouz873563
14Pythonleonid933333
15C++nn953263
16PHPclock1102818

return top