"Christian von Kleist" <cvonkleist / gmail.com> writes:

> I had this as an assignment for a class once, in Java, so I'll sit
> this one out.  Fun quiz!

Well, doubtless in java you solved it in a way that demonstrated your
use of certain basic data structures that you'd just learned about.

There are at least two completely different algorithms to use in
solving this in a conventional manner, and I've just solved it in a
third, completely unconventional ("evil") manner.  So solve it in a
manner different from what you did in class.

(The no-spoiler rule makes phrasing this reply difficult)

Also, being strict about the minimal parentheses rule makes things a
bit interesting:

'1 2 + 3 4 + +' should become '1 + 2 + 3 + 4'

But:

'1 2 - 3 4 - -' should become '1 - 2 - (3 - 4)'

Likewise for multiplication and division.

Also, you could add exponentiation, but if you do remember that infix
exponentiation associates to the right, not the left, so:

'2 2 ^ 2 ^' should become '(2 ^ 2) ^ 2'

But:

'2 2 2 ^ ^' should become '2 ^ 2 ^ 2'

So really, there's lots more to it than whatever you did it in that
java class.

-- 
s=%q(  Daniel Martin -- martin / snowplow.org
       puts "s=%q(#{s})",s.to_a.last       )
       puts "s=%q(#{s})",s.to_a.last