re: Daily Challenge #6 - Grandma and her friends VIEW POST

re: Take this comment as a commitment to do this challenge sometime over the holiday weekend, pinky promise!

Here I am to fulfill my promise!

I followed the directions at:

Buttt... Even then they left something to be desired lol

But I made do! I made a few assumptions, changes to the rules.

The one rule I ignored (because honestly I didn't read it till later) is:

If a town Xi is not visited you will suppose that the triangle
X0Xi-1Xi+1 is still a right triangle.

I'm gonna justify it by saying that this rule means that the map changes depending on where Granny goes. I didn't think granny's plan should alter the map, but also I kinda just didn't read that rule!

I also created the rule that there are only roads between adjacent towns, and there is a road from each down to your grannies Home town. This makes the map a lot like the wheel and spoke map that is drawn in the linked problem.

These two rules combine to mean that not every map is valid, so I return an Error when we encounter an invalid map.

This change of rules, actually led to some more complexity lol. Now it wasn't straight forward what the best path from any arbitrary town to another was. Maybe you should travel "town to town" and maybe it was better to go home in the middle.
I take whichever of these two paths turns out to be shorter!

It's close to 200 lines, so instead of posting it here I'm just gonna post a link to the Github!

code of conduct - report abuse