Draft
The shortest path between two cities
Loading description...
Algorithms
Graph Theory
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 random tests are a joke: it reuses the same graph used by the fixed tests for the entire test suite and only chooses random cities between 16 possible cities. This can barely be called random.
It is not explained what the 3rd argument of
findShortestWay
does, and it is always supplied with0
. Is it the author solution's recursion base argument?Dijkstra's algorithm is a duplicate to existing katas.
The solution setup is
class Node { /*...*/ }
but the tests want aclass Graph
. "storage [...] contains [...] edges of this vertex as values of this vertex." I don't understand that. "Should contain method add()" Why do you require this method when it is not called in the three main tests? Why do you pass0
as a third argument tofindShortestWay
? The random tests just callfindShortestWay
twice and compare the results. Better compare with your own model solution. A native speaker should go over the description.Also: You start with cities and distances, then continue with a generic undirected graph (vertices, edges, weights). You should mention that all weights are non-negative or Dijkstra won't work.
Thank you for your feedback! I changed the solution setup. Initially I called class Node but then decided to rename it and changed description and test cases, however, unfortunately, forgot about the setup.
"storage [...] contains [...] edges of this vertex as values of this vertex." - for example, if storage: {"A": {"B: 500", "C": 300}} it means that point "A" is connected with two point: "B" (distance between them 500) and point "C" (distance is 300). Of course, in this example storage also should contain keys "C" and "B" because since graph is undirected, you can travel both ways. So, the whole property should be {"A": {"B: 500", "C": 300}, "B": {"A": 500}, "C": {"A": 300}}.
"Should contain method add()" - well, you have got a point here. It is not really required for the solution, but I thought about giving some ideas of how the problem can be solved.
"Why do you pass 0 as a third argument to findShortestWay?" - I do not require others to do that, so did not mentioned in the description. Personally, I use it to set up the initial value of starting point in Dijkstra, and for recursive call handle this argument in other manner.
Well, I start the description mentioning about graphs. All the story about cities is just for making the problem description a little lively, because I thought that problem for, lets say, begginners in programming since all experienced developers for sure really keen on graphs, DFS, BFS and so on. So probably for these begginers description containing boring math terms would not be very inspiring, so I desided to make less abstractive and more real life related
I do not really get a point random test issue. I am sorry that is my first kata, it is open for contribution and if anyone would be so kind to help me make it better, I will very appreciate that.
"storage [...] contains [...] edges of this vertex as values of this vertex.": I should've phrased that differently. It's easy to understand by looking at the tests, but this part of the description should be rephrased to make it more understandable.
Look at other katas. Most of them have a model solution in the tests and the random tests just call the user's solution and that model solution and compare the results. I would have done that for you but you unchecked "Allow contributors".
I think I might understand what you mean with random tests, so I changed it now. Anyway, contributors are allowed now, so I would be very pleased if you have a look
Needs Random Tests.
.
Missing sample tests.
Thank you for your feedback! Both added.
.