Or just notice that the sum of nodes capacities is odd : 3+2+2+2+3+2+1 = 15
Which makes the map impossible to solve as each link reduce the total capacity by 2, and youâre aiming for a final capacity equal to 0.
I spent so many hours doing this puzzle without backtracking coming up with all these elimination rules. Then I go on the forum and see your post that there was a webpage explaining it all ><
I must say though that that page presents different elimination strategies as if theyâre all independent specific cases when in fact in my code some of them fall in the same category. For example cases 1,3 and 4 on that page are cases of having as many links to put as places to put them in. 2 and 5 are cases of having 1 less link to put than spots to put them on therefore you canât possibly not be linked to one of your neighbours able to receive 2 links.
Hi guys, I successfully completed testings 1 to 12. My program find no solution for 13. Can you guys show me your result for this one ? Many thanks in advance
Hi,
I got trouble with the CG test with my code. Actually, the test pass, but test in the submit section failed.
Can someone explain me whatâs the logic in the puzzle ?
Hereâs the replay : Replay
I also had to hack my âbeautiful solutionâ to add a specific case for CG tests. What I do is that I apply some rules to find the link that can be filled âeasilyâ (it allows me to past 10 tests out of the 13). Then I do a backtracking, redoing the rules after each choice to fill the grid faster. But after that, CG still fails.
I basically had to favor close nodes in the backtracking to have CG working but Iâm not fan of this. Are there some people that have cleaner solutions ?
Okay so for now I have a heuristic / greedy approach with no backtrack able to solve any case except the last one (Expert). Did anyone manage to solve it this way? Or is the trial and error method using backtrack mandatory?
I have tried the first method and it works for some test cases, but not for all and itâs not just because of timeout.
For now my program iterates over nodes, and i think it could be easier to iterate over links (potential links).
What kind of loop did you do ? Nodes or links ?
Other question, what is your method to avoid crossing links ?
Mine is not actually a test : I update nodes to remove the neighborhood relations when i create a link which go between two nodes. (Am i clear ?) It works but itâs more difficult to rollback and it can be time consuming.
Have you some advice about this point ?
Last short question : how debug an algorithm which calls so many times recursively a method ? Iâve tons of log (for the Expert test case)
Iterating over all the nodes or links until saturation is too time consuming. What I do instead is that I maintain a queue of nodes that need to be examined. Initially all nodes are there, and whenever I update something I enqueue the few nodes that may be impacted.
About crossing links. What is so time consuming about rolling back with your overall approach? All you have to do is restore the full snapshot of the state at the last backtrack point. I chose to pre-compute all the static information (e.g. neighbor nodes, which links cross each other) and keep it separate from the mutable state (number links, remaining slots, etc.), but you do not have to do the same.
I debugged by carefully observing each new link introduced by my algorithm and its effects on the state. Do not hesitate to reproduce the testing grids and run a debugger offline.