OK, this looked like a monster a week ago, but I solved it with simple recursion and cycle detection, which felt like brute forcing but I guess is actually DFS. Can’t be easy with a high level concept like that, but isn’t too challenging either. Medium difficulty seems about right to me.
Ugh, the tag for existing puzzles is DFS. I like that someone decided this should be “Depth first search” except now I have both skills.
Updated the difficulty to medium since that seemed to be the general consensus. Thanks for all the discussion everyone! This was my first puzzle submission, and hearing all your feedback has been super helpful. Hope you all enjoyed it.
Hi !
I only get a 83% score because of the validator 4 which fail.
But I can’t understand why since my solution isn’t “hard coded”.
I used a loop which first detect every players (A, B, …) before applying DFS.
The message about hardcoded solution is just a general information.
If your code fails one of the validators it means that it is not handling one of the edge cases correctly.
You can experiment with Custom test cases to try and figure it out (you must enable Expert mode in settings to see it).
Try something like this (not the actual validator, but similar):
I had the same issue and couldn’t find the issue until I saw the new testcase in here since I was using a > instead of >= in one place.
An extra testcase with the shortest longest road (5) would be great!
Hi there, great puzzle to work on your fundamentals i.e., not too long, nor too hard, but with some twists to keep it interesting.
I have come into a bit of a headache with validator6 which was the only failing test, it must have an interesting edge case, that should be implemented in the regular test case for exhaustivity.
Hello, my code does not pass the last validator 6, for each related component (one per character) I search the diameter of the spanning tree with two successive dfs, is it a false lead? My code works for the 5DN1L example with C 5. What is the particularity of the last validator?
Thanks, problem solved. My algo of diameter search by related component cannot work because some nodes count in the distance calculation and others do not. A calculation running a dfs from all possible nodes is enough.