Ouch, that's a good point. Well, I don't think there's any way to solve that problem with the data that's provided. The operator hash would need to specify which operators are commutative and which aren't.
In fact, the problem requirements state:
Operations of the same priority can be considered to be commutative, and can be evaluated in any order.
So, I solved the problem as stated, although the problem as stated doesn't quite reflect actual arithmetic.
Update: Oops, I'm confusing commutative (order doesn't matter) with associative (grouping doesn't matter). Subtraction is neither commutative nor associative, but the problem MeowChow pointed out involves associativity. The operator hash would need to specify which operators are associative. Either way, there's not enough information available for a perfect solution.
The purpose of associativity is to resolve ambiguities between operators of equal precedence. Associativity isn't specified on a "yes/no" basis, but on left-to-right, or right-to-left basis. All trivial arithmetic operators excluding exponentiation are left-to-right.
Ok, it's probably going to depend on how you decide to pop off the stack. Given "N1 N2 o" in RPN where N1 and N2 are the numbers and o the operation, the LTR should be "N1 o N2".
Yes, '/' would need to be 4. And yes, the second one poses the problem if there's no indication of order being important on an operation ("a op b" not being equal to "b op a"). Chipmunk's got part of the problem with associtivity in his 171 char solution, but I might need to restate the problem to handle this concept; at the time, I was only aiming for a general solution assuming that order didn't matter.