The shortest way to convert infix expressions to postfix (RPN) in C
Posted
by
kuszi
on Stack Overflow
See other posts from Stack Overflow
or by kuszi
Published on 2011-01-06T23:33:28Z
Indexed on
2011/01/13
5:54 UTC
Read the original article
Hit count: 224
Original formulation is given here (you can try also your program for correctness) .
Additional rules:
1. The program should read from standard input and write do standard output.
2. The program should return zero to the calling system/program.
3. The program should compile and run with gcc -O2 -lm -s -fomit-frame-pointer.
The challenge has some history: the call for short implementations has been announced at the Polish programming contest blog in September 2009. After the contest, the shortest code was 81 chars long. Later on the second call has been made for even shorter code and after the year matix2267 published his solution in 78 bytes:
main(c){read(0,&c,1)?c-41&&main(c-40&&(c%96<27||main(c),putchar(c))):exit(0);}
Anyone to make it even shorter or prove this is impossible?
© Stack Overflow or respective owner