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: 199

Filed under:
|

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

Related posts about c

    Related posts about code-golf

    • Code Golf: Collatz Conjecture

      as seen on Stack Overflow - Search for 'Stack Overflow'
      Inspired by http://xkcd.com/710/ here is a code golf for it. The Challenge Given a positive integer greater than 0, print out the hailstone sequence for that number. The Hailstone Sequence See Wikipedia for more detail.. If the number is even, divide it by two. If the number is odd, triple… >>> More

    • Code Golf - p day

      as seen on Stack Overflow - Search for 'Stack Overflow'
      The Challenge The shortest code by character count to display a representation of a circle of radius R using the *character, followed by an approximation of p. Input is a single number, R. Since most computers seem to have almost 2:1 ratio you should only output lines where y is odd. The approximation… >>> More

    • Code Golf - PI day

      as seen on Stack Overflow - Search for 'Stack Overflow'
      The Challenge The shortest code by character count to display a representation of a circle of radius R using the *character. Followed by an approximation of pi Input is a single number, R Since most computers seem to have almost 2:1 ratio you should only output lines where y is odd. The approximation… >>> More

    • Code Golf: Triforce

      as seen on Stack Overflow - Search for 'Stack Overflow'
      This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383 The Problem Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the console, arguments are less desirable. When the input is 1, print the following: *********** *********… >>> More

    • Code Golf: Tic Tac Toe

      as seen on Stack Overflow - Search for 'Stack Overflow'
      Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player 1 (X) 2 = player 2 (O) So, given the array b… >>> More