TAN Network puzzle discussion

Haha i had the same issue.

1 Like

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:

1 Like

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

1 Like

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.

sorry, i have same issue with slava_spamec, can’t i ask is it right about test 5th which has a link linking the stop to itself, such as"stop a stop a". ?

Ok I finally beat the game at my 4th day working in that problem. Finally :slight_smile:
Your answer got me on the right track.
I made a test case to be able to identify my problem. It helped me found was I was doing wrong In my code. So I put it here if someone need it.

StopArea:ABDU,“Abel Durand”,47.22019661,-1.60337553,1,
StopArea:ABLA,“Avenue Blanche”,47.22973509,-1.58937990,1,
StopArea:ACHA,“Angle Chaillou”,47.26979248,-1.57206627,1,
StopArea:ABDU StopArea:ABLA
StopArea:ABLA StopArea:ACHA

Abel Durand
Avenue Blanche
Angle Chaillou

My code was not working in this case because ACHA was never in the “links” list and when I checked his distance propriety my code throw an error because he didn’t exist.

Similar problem to: @slava_spamec, @Rafalon and @Unihedron, beside that I have no Gaston Veil stop. I’m getting following distances:

  • 1.497307141189208
  • 0.3348154821409763
  • 0
  • 2.3022053696674005
  • 13.424056863058826
  • inf

Stop list:
stops: 27 [‘EINS’, ‘GERA’, ‘PCSI’, ‘RVRE’, ‘RTSC’, ‘ECSU’, ‘FACU’, ‘MORH’, ‘MICH’, ‘SFEL’, ‘MOTE’, ‘SMHI’, ‘OTAG’, ‘CRQU’, ‘COMM’, ‘RPBL’, ‘PIRM’, ‘PROU’, ‘MAI8’, ‘BALI’, ‘MELI’, ‘XREZ’, ‘MHUI’, ‘JGUE’, ‘JVAL’, ‘LAIL’, ‘GALH’]
endpoint: [‘Galheur’, 13.424056863058826]
Petite Censive
Recteur Schmitt
Ecole Centrale - Audencia
Motte Rouge
50 Otages
Place du Cirque
Pont-Rousseau - Martyrs
8 Mai
Croix de Reze
Moulin a l’Huile
Jules Valles
Les Ailes

It seems that algorithm goes in a wrong way. Que is sorted from the smallest distance. Looking forward for your remarks as I feel annoyed I cannot find the bug.

What is the point of the “5 stops, 2 routes” validator? I could pass every other (“large number” included) but not that one((

I’m clueless. :frowning_face:
05 Large number of stages

Should go:
Rene Cassin

but my algo goes:

which is strange, because GERA is closer:
[[0.3901467877398925, ‘GERA’], [0.41235770095082147, ‘RCAS’]]

Any hint, where I made assumption mistake?

I liked this puzzle because it handles real data and problem. But I think there should be at least 2 more passing test:

  • one to check that algorithm don’t take path in reverse B->A when there is only A->B,
  • another to check distance are well calculated, i.e well converted in radians, with maybe data where two path that have almost the same distance.

Also there should be an example in statement of a distance calculation (with A(lat, lon) and B(lat, lon), distance is exactly N)

I get errors only on the large dataset test, and even the large dataset after submit, so it took me time to figure out what were the reasons.

Thanks to this thread it helped me.