Day #3
I was in real hurry with this one. So I decided to approach this 'systematically' in top-down style. I wanted to do some generator chaining but in order to get ready before my time was up I didn't follow this initial thought. Also - I did vectors decades ago, so I let shapely and numpy to do heavy lifting. This is brute-force and probably there is some math which allows to reach same result with less work.
Puzzel # 1:
'find intersection point with smallest Manhattan distance from start (0,0)'
For that:
Puzzle # 2:
Intersection points were already found. So:
'Find smallest distance to intersection point' (function 'shortest_distance' in code above)
I was in real hurry with this one. So I decided to approach this 'systematically' in top-down style. I wanted to do some generator chaining but in order to get ready before my time was up I didn't follow this initial thought. Also - I did vectors decades ago, so I let shapely and numpy to do heavy lifting. This is brute-force and probably there is some math which allows to reach same result with less work.
Puzzel # 1:
'find intersection point with smallest Manhattan distance from start (0,0)'
For that:
- read data from webpage
- calculate relative moves
- calculate path using relative moves
- convert into shapely LineString
- find all intersections
- find smallest Manhattan distance from intersections
- output smallest Manhattan distance
Puzzle # 2:
Intersection points were already found. So:
'Find smallest distance to intersection point' (function 'shortest_distance' in code above)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.