Retired
Transform the graph (retired)
50nevepura
Loading description...
Data Structures
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.
you need to remove the tabulation character in the initial solution, and replace it with 4 whitespaces (or a tab char, but produced through cw's editor: cw is using exclusively whispaces, replacing tab char automatically, and this code comes from your editor which uses actual tabulation char. And this is annoying for the user, because it raises this error.
Cheers
thanks, fixed
Random test input is subject to manipulation.
How, exactly? Could you write it in a comment marking it as spoiler?
This comment has been hidden.
Right. The input data could be forged. I didn't think about that. That wasn't in the spirit of the problem solving, but still possible. Fixed now, thanks.
Not yet: you only did a shallow copy. Meaning the sets are still mutable on the user side with side effect. So:
and the error messagebefore you call to the user's function.cheers
edit: actually, just remove the message: this is exactly what the default message is supposed to be, so you're actually printing it 2 times (the provided message is always added to the default one)
Done both :smile:
Hi,
Afaik, the input isn't an adjacency list, but a dict of sets of successors. An adjacency list would be represented by a list of lists of successors (btw, it's rather obvious with the examples, but you should clearly specify that only directed graphs will be used).
Cheers
Yes. I had the doubt about how to represent the adjacency list. I've seen it represented both as list (of sets of successors) and as dictionary. As a dictionary it is convenient in some cases. In this problem it's the same. Do you think I should change it, and put the list?
About the directed graph, sure, you are right, i'll edit the description. Thanks.
no, you can keep the current setup, just update the description, talking about dict of successors (and the orientation thing).
Before editing, there's only one thing I disagree with. I'd say "dictionary of sets of ints" and not "dictionary of sets of successors". I don't see how the sets contain successors: the elements of a set aren't ordered nor contiguous. Only in some example they look like so, but actually they are not. So, any reason for "successors" to be there?
No, that wouldn't be enough if not actually incorrect.
In your example, 2 is the successor of 1 because there is an arc going from 1 to 2. that has absolutely nothing to do with the numbers themselves, but only with the "configuration" of the graph itself. As a matter of fact, 2 is a successor of 3 as well as 3 is a successor of 2. Limiting the wording to "dict of sets of ints" is sort of forgetting half of the reason why you build that structure (because one could provide the very same graph as a dict of sets of predecessors, and then you wouldn't have the same dict while both structures are describing the very same graph).
Alright, now i've caught up with terminology. Edited the description, how is it now?
all good, except I'd change the first 2 lines:
to:
I like it. Updated. Slightly changed: i've put the last purpose in the input section. Marking this as solved.