the result should be completely determined by the last few elements (1.744643 4.996892 - 2.643301 1.966982 -0.633035 + * +) and should be 0.273774439047. The preceding numbers and operators can only affect the result if more operators are added at the end. And yet the expected value is 1.6180521.
I have been using an RPN calculator for many years and the current behavior is exactly what I would expect. I don't think ("1 2 3") should be invalid. It's pointless, but not invalid.
Fixed
The apostrophe in "it's own digits" shouldn't be there.
Let me elaborate. In the case of
-2.773338 2.707978 0.256819 2.688138 - 3.338837 0.594497 + 3.652114 4.419055 * -4.161358 4.40141 - 1.664405 4.172521 / -4.409798 -4.278772 / 4.755362 0.334755 - 3.956 -0.861461 - 0.04399 -3.601651 - 3.994258 2.716964 - 0.094607 -4.672443 + -3.406174 1.57852 - 3.267372 -3.19572 + / - -2.338969 1.174953 4.090432 / + -4.319612 1.561592 2.250668 + - -2.567241 -2.759615 / -1.322895 4.750919 + -4.502398 -0.158941 * 2.76282 -1.289143 * 3.114361 -1.892853 * -0.222153 -0.184301 / -1.054062 2.219888 1.301827 * * -0.999579 1.165472 / -0.478222 -3.618794 2.17705 - 3.348073 -4.026311 - -4.669369 2.389605 3.088028 - 1.35393 0.647554 4.124007 / 4.936135 -1.030017 - 4.12736 3.34695 2.909127 -1.180229 + 1.513544 -2.291515 / -0.363779 0.708222 0.387678 / 1.563595 3.223302 + 0.999638 -2.488148 * 2.985529 -0.130778 + 1.744643 4.996892 - 2.643301 1.966982 -0.633035 + * +
the result should be completely determined by the last few elements (1.744643 4.996892 - 2.643301 1.966982 -0.633035 + * +) and should be 0.273774439047. The preceding numbers and operators can only affect the result if more operators are added at the end. And yet the expected value is 1.6180521.
Fixed
Nice kata, but please correct the spelling. "At it's simplest" should be "At its simplest".
I have been using an RPN calculator for many years and the current behavior is exactly what I would expect. I don't think ("1 2 3") should be invalid. It's pointless, but not invalid.
Random test for PHP is incorrect.