Beta
One Line Task - Travelling Salesman Problem
Loading description...
Restricted
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.
ok, look here, please: https://www.codewars.com/kumite/67928fddb47458a990ee6388?sel=67991f05b3e3da841ece0758
score += expected_cost / actual_cost
, which seems wrong to me, because an accidental huge diff will weight more on the final value while, in the end, what you actually want to test is that both solutions are randomly behaving "the same" (aka, sometimes exp is bigger, sometimes it's smaller).score += exp_cost /actual_cost
, the value increases when exp is worse than actual.Funny thing is that the test isNope, that part is ok, I'm just too much tired.(t-score) <= 0.925 * t
which means the actual solution has to be better than the expected one to pass the test. No?In the end:
totally wrongnot lax enough, as far as I can tell. A better measurment would be imo to do the following:Well, I didn't realize I was working on an updated version of the tests. My solution consistently passes, now, so in the end, I guess the tolerance is actually lax enough.
The reason I do tests like this is such that if your solution does worse on some tests, but does better on others, it can cancel out.
Yes, I got that part. The problem was that with a not large enough tolerance, accidental "not optimal cases" could sometimes weight too much. But now it looks ok, so "anyway".
this assertion is incorrect:
Messages are swapped.
(you should aslo use a dedicated function to do all the fixed tests, rather than duplicate the code in the sample tests and the full test suite several times. You'd need to define the function twice, tho: once in preloaded (for the sample tests), and once again at the beginning of the full test suite, so that the user cannot override it easily).
and this message is useless to the user:
=> add the cost and the threshold to the message
test.it
message, so that the user always know "where he is" about that.ok, I got the char limit, but I think your cost function is too much strict: I get these in the random tests:
while I definitely implemented what was asked for.
=> ?
I see you have already solved the kata, so I cannot see the code that should work but doesn't. Could you please send it here?
it's the very same code. It fails roughly 70% of the time, I'd say (maybe even more)
edit: the main diff is that yours uses kind of a randomized order to explore the decision tree, because of the set, while mine explores the decision tree always in the same deterministic order. Not sure how it affects your testing process, but that's the only meaningful diff I can see.
edit²: it got invalidated because you changed something. If ever you need the link, it's here
Weird. Your code should pass, but it's not. I'll add a little bit of tolerance, such that you can pass with 49.95 points at least for a test suite of 50 tests.
EDIT: I won't do this, for those who can't see my spoilered comment below.
EDIT 2: I will add a 50/50 chance of this happening actually, just for fun. What could possibly go wrong?
This comment has been hidden.
What's this cost "exactly"? if you just add tolerance, you'll need to add a bit more. iirc, I got some lower values, also
why did you close the
issuequestion? The tests are still wrong.What are you talking about...? It's not about chances, it's about the cost function not behaving properly. => don't rely on luck, fix the tests.
I closed the question as the problem is in your
key
parameter.Prove it?
How the output would be wrong?
To be clear: either my code is wrong and it shouldn't pass consistently, or my output is valid considering the specs and the cost function is wrong. Afaik, it's option 2. In any case, this is actually an issue.
It might be to do with tuple comparison. But I don't know. I have added a tolerance anyway, that's not a 50/50.
You're not answerig my questions/problem.
=> ?
The cost function traverses the path and calculate the total distance cover by the path. Your task is not to find an optimal path (in 120 characters, it is impossible AFAIK), it is to implement the nearest neighbour algorithm.
But that algorithm doesn't garantee actual optimality. So the testing process definitely looks wrong to me. Unless you can prove otherwise.
Hi,
test.expect
without providing a useful error message to the user.[0]
, though, the sample tests do not raise any error when it's not the case. So, what's the actual ouput format? => an actual example should be given in the description.(damn it, Iget
120124 chars... x/ )should be fixed, confirming it is tho
yeah, should be fixed now (resolved to publish)
(you didn't need to close the issue to republish, normally)
oh mb, but is it fixed now?
that part, yes, but you created another problem
could you please share it?
see issue at the top