Considering the puzzle tags, I suggest you look into the basics of graph theory
Hi,
please donāt give the solution, youāre hint was very good and let people search.
Thank you
Hello all,
I tried this puzzle in C and passed all the tests, but 0% when I submitted my code.
I went into the contribution section and hit the ātest in IDEā button to run both tests and validators: I pass them all.
I donāt have this with any other puzzle, so far.
Anyone knows this, please?
Thank you
IDE tests are run in debug mode and validators in release mode. Weāre assuming you have a memory issue.
You may be right, thank you.
I use ad-aware browser no more supported with hundreds of tabs, and my computer is on for days. Despite, memory usage is 55% and swap usage 30%, and still I can submit my code for other puzzles. Anyway, Iāll switch it off and try again later, Iāll let you know if it continues.
Thank you
An accurate description is not āholding your handā. The other puzzles on CodinGame, for the most part, have clear, accurate descriptions. āAssumingā an ideal starting point is not as clear as, for example, āOut of all possible starting pointsā¦ā
LOL
I spend enough time correcting them to have a fair idea of the general level.
In any case, thank you for writing out your rewording suggestions. I donāt wish to merge it in the statement, but theyāll certainly help someone by being here.
In other words, you prefer to keep a less accurate description even when you see that more than one person has to come here to clarify.
In other words, you prefer to keep a less accurate description even when you see that more than one person has to come here to clarify.
āLess accurateā is merely your opinion, Iām afraid. You might share it with 3 people in this thread, but it was fine for myself, all three independent moderators who approved it, and the 130 other CodinGamers who solved it. The arguments you used in your debating here, for now, have only comforted me in my opinion.
Let it be clear that I do think itās less clear. And thatās the point.
My solution is essentially just performing a BFS on each of the nodes to find the one that requires the smallest depth to traverse them all. With BFS, you should most likely be using the deque
from the collections
package so that you can push and pop from opposite ends of the queue in an efficient manner (itās a doubly linked list).
Another trick is to keep track of the smallest depth found thus far, and short-circuit any ātrialsā that reach that depth because you know they wonāt be any shorter and can thus continue to another node to start from without fully simulating a longer infection.
Essentially:
- Keep track of current min
- For each node:
- Simulate infection with BFS
- While simulating, if infection nights >= current min, stop
- Otherwise, current min = infection nights
- Tada
This puzzle reminded me of the Teads sponsored medium training puzzle that I solved 2 months ago. While I donāt find that puzzle on the site anymore, I have the saved the code.
Interestingly it tests/validates to 80% without any modification at Plague Jr test, but with āadvanced caseā I find graph diameter of ā10ā vs the expected answer of 13.
Now I am stuck: I donāt find the real difference between the two puzzle problems and I donāt understand why 13 is the answer to this case (though I admit I did not draw the graph of 999 vertices).
Any hint from experts?
The Teads puzzle disappeared (was a sponsored one).
So JBM made a completely new puzzle without any reference to possibly existing ones
I would guess, that your solution to the original Teads had a bug not covered by the given testcases back then.
Hey Iām completly stuck ā¦ solved all cases but the advanced one. Iām finding a solution in only 5 nights instead of 13ā¦ what am I doing wrong ? Iām using a tree diameter method.
Why canāt I use networkx ? It complains with ModuleNotFoundError: No module named ānetworkxā
Isnāt it pretty standard ?
@thanos.a Your question is not specific to this puzzle and you should mention the language when asking such a question (Python). The available libs are listed in the FAQ. networkx
is not particularly āstandardā and solving puzzles by calling libs that do all the job to the rescue is arguably not very interesting.
Thanks a lot for the suggestions and the link.
sys.setrecursionlimit(2000)
Thank you - recursion limit was stumping me
Hello, thx for the tip, however i donāt get it with your sentence āYou donāt need to tell which node is in the centerā.
Isnāt it the aim of computing diameter to find the optimal starting node ?
The goal is to find the node with the littlest maximum length with all other nodes, right ?
The goal is to find the node with the littlest maximum length with all other nodes, right ?
To use your words, the goal is only to find āthe littlest maximum length with all other nodesā. (see the difference?)
It could possibly help to find ātheā node as well, but itās not a requirement from the puzzle statement itself.
OOOOOOOOOOOhhhhhhhhhhhhhhhhhhh (imagine the āaliensā in toy story)
I think i get it, no need to use a āspreadā machinary, as long as you can guess the less time it should take to link the farest nodes.
thx a lot, it saves a lot of computing time moreover.