TAN Network puzzle discussion


Haha i had the same issue.


Me too, i did a mistake with the radians conversion... and i searched for hours why only the fifth submit test fails!
Thanks for the tip :smiley:


passed this with a* for the first time, coded in c++, got no problem in case 5 tho.
there's a very familiar verson of this puzzle, called "Defibrillators", in the easy puzzle, where you too have to calculate the distance of two points based on their lat and lon after converted from deg to rad, if anyone has done the puzzle they might not go through the radians to degrees mistake thingy


Weird, I had a seemingly wrong answer on #5 :

  • ...
  • Commerce
  • Republique
  • Pirmil
  • ...

where the solution is supposed to be :

  • ...
  • Commerce
  • Hotel Dieu
  • Aime Delrue
  • Vincent Gache
  • Wattignies
  • Mangin
  • Pirmil
  • ...

Couldn't see any reason why my algo got the wrong result (radians OK, inverting lat/long doesn't change anything,...) so I submitted anyway and got 100%.

Not sure what to think about this...

Edit : Oh cr*p ! Right after posting, I realized I forgot a condition in the update of cost and heuristic ! Now I've got the right result !


I'm having a weird issue possibly within the algorithm itself, and this is the first time I've implemented a Dijkstra (thanks codingame for giving me motivation on that). I can't even pass all the IDE tests (stuck on test 05 -large number of stages-, the rest are ok) Comparing previous help on this thread, I've compared and made sure that I've used radians, implemented distance properly (and final distances match up with the ones listed here) except case 05 which is of 13.424056863059045

When debugging, I'm noticing that my code never finds a replacement path for existing nodes, which is weird. My current code is something like this: (pseudocode)

[redacted for obsoleteness; view post history]

solved: I had an incorrect implementation where I was looking at the wrong path in a specific edge case.

If anyone can point out if anything jumps out at them, please do share. I've been debugging this for two days now.


Hi All,

Just a short feedback. I had the same result as slava_spamec.
And I was sure to have a correct dijkstra, units in radians and no inversion in lat/lon.
After a few logs, I realized that none of my nodes had coordinates initialized at all. They all had 0/0 in lat/lon. What a stupid bug !!!
But even with that, I was still passing correctly all the test except #5 .... dijkstra power :slight_smile:
Of course, after correction, #5 passed like a charm.
To sum up, review carrefully your code, something very basic and stupid is hiding somewhere. And don't really trust the fact that you passed test 1,2,3,4 and 6
Good luck ....


That's my problem!! Thanks!


Thanks, I also overlooked the degree/radian problem, and was wondering why only the validation did not run through ...



There is a minor bug on the display of the description of the "Tan Network" puzzle: some html is displayed as text.

Kind regards


Does anyone know how to get test cases for debugging outside of CG?
I cannot print more than ~100 lines of text in Console Output Window.


Ok, Problem solved (the hard way). Anyway, you can download test case 03 from here:


In the top right edge of the test cases, there are three lines. When you click them, you will see each test case input and output. Doesn't work for round based puzzles, though.


Wow. Thanks a lot, I don't know how I could have missed it :slight_smile:


I really disliked this puzzle as it taught me only about anger management. I got Dijkstra right for the first time, but I missed

  • converting from degrees to radians
  • longitude and latitude order in input
    also browsing the forum a typical mistake is
  • name is not unique (and I cannot think a reason to have two stops with the same name in a city…).
    Unfortunately these really don’t teach me anything other than you should spend more time reading badly designed inputs than solving a problem.