6 kyu
Evaluating prefix Polish notation
400 of 712interphx
Loading description...
Parsing
Mathematics
Algorithms
Lists
Strings
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Possible duplicate of https://www.codewars.com/kata/reverse-polish-notation-calculator/
Julia translation
I get weird errors running tests, and I don't think my code is the culprit:
My code runs fine locally with the same expressions. Am I wrong?
looks like you're returning a tuple at some point, tho
You're right, my bad.
Why I am getting this error Traceback (most recent call last): File "/runner/frameworks/python/cw-2.py", line 111, in wrapper func() File "main.py", line 51, in fixed_set1 test_it('0',0) File "main.py", line 45, in test_it test.assert_approx_equals(calculate(s),n,margin=1e-6) File "/runner/frameworks/python/cw-2.py", line 84, in assert_approx_equals div = max(abs(actual), abs(expected), 1) TypeError: bad operand type for abs(): 'str'
Here is my python code
you are pushing strings on the stack instead of numbers ;-)
Python translation awaiting approval.
Made some tweaks to improve the generation of random tests.
:D
the description should be updated, saying expicitly that in python one should use true division, and not integer division (for now, the example of the description doesn't allow to be sure of it)
The initial solution setup includes the comment
# should return a float
. Coupled with the fact that the division operator used is/
rather than//
, shouldn't that suffice?woops, I actually didn't even read that comment... x)
Could be enough. Tho, that means the user cannot have the info before he reaches the trainer. It's a bit suboptimal, even if nothing critical, I guess.
I went ahead and added the following comment to the initial test setup as well:
# for division, use true division, not floor division
, so no room for ambiguity. :):+1:
Prolog translation
Thanks for the translation!
Haskell translation
Great, thanks for the translation!