3 kyu
Magic Compare
185Axure
Loading description...
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.
only leave should_work_for_random_tests fail, why?
This comment has been hidden.
Seeing that you've eventually solved this without segfaults, do you wish to resolve the outstanding issue or is there something still unresolved?
Nothing unresolved remaining.
The description has
We have to write cumbersone a < b && b < c && c < d instead of simply a < b < c.
However, these are not equivalent, as there nod
in the second expression.I've passed all tests except random with results:
Expected: false Actual : true
That's not too much clear. In most katas we can make debug output of incoming data, but here incoming data is the expression itsels.
Then question: how can I see the case I failed on?
I had simular issue. You should check if you processing correctrly cases where more then two chained operators. Like a < b < c < d.
What is the expectation of the mentioned example in the description: ((a != b) > c != d) < e < f Let's assume a,b,c,d,e,f distinct numbers greater than 1. Should then (a != b) be true, (true (1) > c) be false, (false (0) != d) be true, (true (1) < e) be true ? Then (under the given assumptions) the expression would break down to (e < f)
I feel like I'm failing at the random tests that use the != operator. So I'm wondering if my assumption above is correct.
Example ((a != b) > c != d) < e < f can be rewritten as a != b && b > c && c != d && d < e && e < f. Operator != isn't special, it's like any other operator.
Great kata, had a lot of fun solving it but I would propose to choose a few operators you will be using and pointing them out in the description because in the end we are basically doing the same thing for every operator which is not as fun.
I'm completely stumped by exit code 139, presumably a segfault, running the sample tests in the web interface. I can't reproduce locally and valgrind/ubsan/asan don't see anything wrong in my code. My code does no heap allocations and the vector indexing in the sample tests dont overrun the vector. So haven't a clue. I'm using g++ 7.3 and clang++ 6.0.
Not posting the solution code here (yet), but here's the steps I'm taking locally:
I had the same issue at first. I don't know if you have the same issue, but give the following a thought: What happens if you use your
MagicCompare
instance in a for loop's body for your comparison and then re-use it as your loop index. Hope this helps ;)Good kata. You should have added sample tests with different comparison operators combined, e.g. i < 2*j > k or i == j <= k < l.
This comment has been hidden.