6 kyu
No Order of Operations
202 of 306tonylicoding
Loading description...
Mathematics
Algorithms
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.
I think the test answers use int during every calculation step not only in the end result. Resulting in rounding prematurely and thus wrong outputs
Division in this challenge is defined as integer division. It should be always rounded, it's specified this way.
should include some examples where equation starts with a negative number. e.g.
-2*3
etc.Interestingly, order of evaluation is just a convention. This order of evaluation is the reverse of the APL one. Here is some further reading about this : https://www.jsoftware.com/papers/EvalOrder.htm
Python: The following test (and many random tests with
^
) is incorrect:test.assert_equals(no_order(' 3-15 ^ 8-4 '), -429981700)
The result should be
429981692
because: 3 - 15 = -12, (-12)^8 = 429981696, 429981696 - 4 = 429981692.In Python, the expression
-12 ** 8
is evaluated as-(12 ** 8)
which is not correct for this kata.My solution was approved and was then removed because of this issue, should I repost it, or will it come back by itself into the solutions?
Is there any way to unpublish a kata? All the solutions will be invalidated.
Thing is, solving kata using a one line eval or using an accumulator don't lead to the same result, ex:
I think both results should be accepted by tests or kata instructions should be detailed (like, e.g. no eval() ;)
This comment has been hidden.
I think exponentiation implementation in tests is wrong.
but
Resolving here, same issue above. I'll take a look in a minute
(not a big issue, but)
python (at least): random tests don't include exponentiation
Yes, fixed. Before numbers could go up to 100. Now, only 20 ;-( because 100^100?
How about e.g.
if op == "^": x = random(1, 6)
or similar?@anter69
It's really ok for you to edit. Contributers allowed. Thanks for the effort ;-)
Should include negative numbers, e.g.
3 * -2
However, negative powers may appear in test cases
If you can make an algorithm that can always make non-negative powers, then go for it. Also, how about mods
%
Hi There, i am relatively new to python and this platform. i took this Kata and passed all the sample test, however on the extended test, some failed and on all the failed tests it says something like '45' should equal 45, which doesn't add up as all my answers are int. All my answers corresponds to what the test result answers should be, just says my answer is a string. Please i'll appreciate if my code and the test results are reviewed, cause its quite bothering. Thank you for your help
You've returned it as a string, should be an integer. So, change your return statment to
int(x)
where x is what you returned previouslyThis comment has been hidden.
Thanks for the reply, it has worked out for me. I appreciate your assisatance.
Great job man, love this one. Best of luck on getting it approved.
Awaiting moderator approval ;-)
Approved :smiley:
cheers, enjoyed this one
cheers
It's only running the first one of the tests. (sample tests) (javascript)
The tests only work if the test before it works. For example test 2 is called in and is applied if test 1 is passed. Therefore, issue is resolved.
Please don't put issues on katas if you don't even know what it means.
JS translation
.
.
.
Nice kata! I enjoyed solving it.
both the errors need to be tested in the fixed tests
Fixed.
Such input validation adds nothing to the task.
Edit: don't mind duplicate notifications or any weird behavior related to this comment, I needed to delete it for a bug report.
Ok, I deleted it