5 kyu
The Spider and the Fly
79 of 114dinglemouse
Loading description...
Debugging
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.
the
Debugging
tag seems inappropriateNevermind; this kata has bugs in it.
python translation
thank you for your service
Can anyone explain to me why the answer is not H3-G3-F3-E3-E2? If every step is worth 1?
Because H3-G3, etc. is longer than 1. You can see that in the picture. It doesn't say each step is 1 unit, it says this:
An that means the innermost circle has a radius of 1, the next one a radius of 2, and so on.
I really enjoyed this Kata.
An excellent and original Kata (but hard to debug with so many edge cases ...)
C# reference solution uses bad practice string + string:
Use a StringBuilder instead.
Are you referring to the internal solution on the
SolutionTests
class within the Test Cases?If so, then I don't care what it looks like. Those solutions only need to yield "correct" results; they are not intended as examples of good-practice coding.
Yes, the internal solution. If you are happy with it, case closed.
I didn't write it. It gave correct results, so I approved the translation. End of story ;-)
C# tests should have custom error message. Replace the Console logging with an error message in the assert.
Is there some reason to remove the console logging, or you just don't like to see it?
Actually, for most of my Kata I always prefer to unconditionally log what all the random tests are doing (esp. for languages I am not proficient in) instead of letting them execute silently. Too many times some transalator has assured "everything is fine" but then later I get burnt if the random tests are not doing what they should be doing. The random test logging elimimates most of that risk...
You could keep the logging, but at least I would add the assertion message for better user feedback on error. Console loggin usually is not aligned with the test that failed.
OK, sounds like a good reason. Kata is updated as you suggested. Thanks.
What time complexity is required in C#, I get a timeout all the time, eventhough my solution is O(n), I don't use any backtracking.
Even the sample tests take way too much time -> Time: 3134msPassed: 3Failed: 0. These 3 test cases pass in less than 100 msec. -> why 3 seconds total time? Is this a kata issue?
Dingle! We need your help! We offer cheese!
Issue in our solutions.
Still, no cheese for you...
For people like me who skim through descriptions the picture can give wrong impression that web is made from isosceles triangles rather than circles (only to later notice the keyword
radial
which unlike the picture is hardly noticeable), so updating picture to reflect that would be helpful.No. They ARE triangles.
Seriously, do you really think I would get my own picture wrong and draw triangles if I meant circles?
Radial refers to those web parts that look like spokes of a wheel.
Here is a description https://en.wiktionary.org/wiki/radial
Don't skim it.
I came to wrong conclusions because of miscalculations ... in that case nevermind.
C# Translation added.Please review and approve~
Approved :-)
This kata is weird. However I've made a bunch of tests and figured out a pretty easy solution.
thank you for this kata! hope you enjoy my solution
if spider or fly was "A0",output tell me that "expected:<A[0-A]1-A2-A3-A4> but was:<A[]1-A2-A3"-A4>" but I don't konw why the result was A0-A1-A2-A3-A4 when I use Eclipse.
the four last points do not exist (told in the description)
note: use the back tick to post strings with brackets inside:
expected: [...] but was [...]
sorry,I‘m from china so I can't understand it well,and my expression is not accurate.
the output in codewars was "expected:[A0-A1-A2-A3-A4] but was:[A1-A2-A3"-A4]"
but it turns out that “A0-A1-A2-A3-A4” instead of "A1-A2-A3"-A4" when compile in Eclipse
Uh, sorry, I said shit... x-) The non existing coordinates are B0, C0, ...
I don't understand the quotation mark in the middle of your answer, actually.
If spider is "A0" and fly is "A4" then clearly the correct answer is "A0-A1-A2-A4" like CW is expecting.
Both end points of the path are always in the solution.
If you are asking why does your solution give different results in CW and in Elcipse then I cannot answer that.
I have found the reason,That is the diffferent betwwen "spider == ‘A0’" and "spider.equals('A0')".in Eclipse ,All was right,but in CW,"spider.equals('A0')" was right; thank you for your help,Because that is my first time to ask for help
Ah, that is good news.
I would suggest that the metric by which a path is measured should be included in the description. At the moment, one could assume that all the edges have equal lengths/weights.
It is simply a question about distance - not the number of edges.
If I said shortest length path would that remove the ambiguity?
I guess Euclidean distance would be more than clear. ;)
Hi @SpaceBison. No I don't like to say Euclidean because then some people might interpret that as the straight line distance directly from spider to fly. Instead I have just clarified the requirement by adding another Kata description note. Thanks.
I think I may be misunderstanding. In the scenario presented, wouldn't the shortest path be H3-G3-F3-E3-E2 ? Is there something I am missing on why he wouldn't go this path?
??
How do you see your path shorter than the one going through the center of the web?
Approximation: "the web is made of circles"
length = 3/8*2*pi*R + R/3 = 9pi/4 + 1 = 8.06...
length = 3+2 = 5
Even considering my approximation increase the length a bit, it's clear that your path is longer.
Or try this with out the maths...
my diagram is (kind of) to scale so just zoom it bigger and use a peice of string on your screen to compare those paths and see which is longer
Approved ;-)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
ADVERT
This Kata has bugs in it