Ad
  • Custom User Avatar

    As noted before (there's even a link in the description) this is an exact duplicate of http://www.codewars.com/kata/reverse-polish-notation-calculator/

    Only difference is this have the "^" operator (which would actually make this the "hard" one).

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Python (at least) - int vs float division should be tested in the fixed final tests, because you can easily pass the random tests with a wrong implementation; add e.g.:

    "5 2 /"  -->  "2"
    
  • Custom User Avatar

    Ruby 3.0 should be enabled.

  • Custom User Avatar

    Random tests in C# are broken and suffer from rounding issues. I prefer C#, but had to ultimately solve it in Javascript.

  • Custom User Avatar

    In C#, I get a failure on the random test:

    Run40RandTests
    Log
    3 8 + 19 ^ 10 -
    Expected: 6.1159090448414499E+19d
    But was: 6.1159090448414548E+19d

    So I created a test in Visual Studio that passed in "3 8 + 19 ^ 10 -", and expected back 6.1159090448414499E+19d.

    In Visual Studio, my test passed. Is it some kind of rounding issue between the version of the compiler I'm using and the one Codewars is using?

    Should I just keep trying until all the random tests pass?

  • Custom User Avatar

    Great kata idea but random tests with rounding issues make it a frustrating exercise that soon has nothing to do with RPN.

  • Custom User Avatar

    I get the following failed test:
    Testing for '19 15 7 18 3 - 6 13 19 + 6 * 17 - + - - ^ /'
    "It should work for random inputs too: 0 should equal 6.530790981007351e-203"

    The division should be integer division, as per "Note: for simplicity's sake, assume that the "/" operator behaves like it usually does in the chosen language: float division in JS, integer division in both Ruby and Python 2 (the defaul Python on this site)."

    Using integer division, the results should never be 6.530790981007351e-203.

    Some of the tests seem to use integer division and some seem to use regular division. I have run and analyzed many of the random tests. For example a test says '7 2 + 10 /' should be 0.9. This is not integer division.

  • Custom User Avatar

    I don't think the use of ^ is correct.
    It's used in the tests as a power, but that is never indicated in the instructions, only implied.
    10 5 / 7 + 3 ^ 10 - = (10 / 5 + 7) ^ 3 - 10 = -16 not 719
    ** = power by way of operator