Commit b896b4f6 authored by Alexander Gehrke's avatar Alexander Gehrke
Browse files

[day12] clean up and tikz-based visualization

parent eff6e7ff
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[red,thick] (0,0) circle (2);
\draw[blue,thick] (-53.40, 10.20) circle (2);
\draw[] (0.00, 0.00) -- (0.00, 0.00) -- (-0.50, 0.00) -- (-0.50, 0.00) -- (-0.80, 0.00) -- (-0.40, 0.00) -- (-0.40, 0.00) -- (-0.40, 0.50) -- (-0.40, -9.50) -- (-0.50, -9.50) -- (-0.50, -9.50) -- (-0.50, -8.40) -- (-0.50, -8.50) -- (-0.10, -8.50) -- (-0.10, -1.00) -- (-0.10, -0.60) -- (-0.20, -0.60) -- (-0.20, 6.00) -- (-0.20, 6.30) -- (-0.20, 6.30) -- (-0.40, 6.30) -- (-0.40, 6.30) -- (-0.30, 6.30) -- (-0.30, 6.00) -- (-0.30, 14.40) -- (-0.30, 14.40) -- (-0.30, 14.50) -- (-0.30, 14.50) -- (-0.30, 19.40) -- (-0.30, 19.30) -- (-0.30, 19.30) -- (-0.10, 19.30) -- (-0.10, 19.30) -- (-0.10, 19.40) -- (-0.10, 19.40) -- (-0.10, 19.30) -- (-0.10, 19.30) -- (-0.10, 9.30) -- (0.30, 9.30) -- (0.30, 9.30) -- (0.30, 9.60) -- (0.20, 9.60) -- (0.20, 9.60) -- (0.60, 9.60) -- (3.60, 9.60) -- (3.60, 10.10) -- (7.60, 10.10) -- (7.60, 10.10) -- (8.00, 10.10) -- (8.00, 10.10) -- (-1.40, 10.10) -- (-1.40, 10.10) -- (-1.10, 10.10) -- (-1.10, 4.00) -- (-1.10, 3.60) -- (-1.10, -4.20) -- (-1.10, -4.40) -- (-1.10, -4.40) -- (-1.30, -4.40) -- (-1.30, -3.00) -- (-1.30, -3.00) -- (-11.30, -3.00) -- (-11.30, -3.00) -- (-11.30, -4.50) -- (-10.90, -4.50) -- (-10.90, -4.50) -- (-3.20, -4.50) -- (-3.20, -4.70) -- (2.60, -4.70) -- (2.60, -4.70) -- (2.80, -4.70) -- (2.80, -8.80) -- (2.80, -8.40) -- (2.80, -8.40) -- (2.80, -8.60) -- (2.80, 0.50) -- (2.80, 0.20) -- (2.80, 5.40) -- (2.40, 5.40) -- (2.40, 5.10) -- (2.40, 12.40) -- (2.40, 12.00) -- (2.40, 17.00) -- (2.10, 17.00) -- (2.10, 17.00) -- (-4.90, 17.00) -- (-4.90, 17.50) -- (-4.90, 17.70) -- (-4.90, 17.70) -- (-4.90, 7.70) -- (-5.00, 7.70) -- (-5.00, 7.70) -- (-5.00, 8.10) -- (-4.90, 8.10) -- (-4.90, 8.10) -- (-4.90, 14.40) -- (-4.90, 14.40) -- (-5.30, 14.40) -- (-8.30, 14.40) -- (-8.30, 14.70) -- (-8.30, 14.70) -- (-8.30, 7.10) -- (-8.30, 7.10) -- (-8.40, 7.10) -- (-8.40, 7.50) -- (-8.40, 7.50) -- (-6.40, 7.50) -- (-6.40, 7.10) -- (-5.60, 7.10) -- (-5.60, 7.10) -- (-5.60, 2.40) -- (-5.80, 2.40) -- (-5.80, 2.40) -- (-6.00, 2.40) -- (-6.00, 9.90) -- (-6.00, 15.50) -- (-6.00, 15.50) -- (-9.50, 15.50) -- (-9.50, 15.50) -- (-9.50, 15.30) -- (-9.50, 15.30) -- (-9.60, 15.30) -- (-9.90, 15.30) -- (-14.30, 15.30) -- (-14.30, 15.30) -- (-14.30, 15.10) -- (-14.30, 5.80) -- (-14.20, 5.80) -- (-14.20, 6.30) -- (-14.20, -2.00) -- (-14.20, -4.80) -- (-14.20, -4.90) -- (-14.20, -4.90) -- (-14.20, -4.50) -- (-14.40, -4.50) -- (-14.00, -4.50) -- (-18.80, -4.50) -- (-18.80, -4.20) -- (-25.30, -4.20) -- (-25.20, -4.20) -- (-25.20, -4.20) -- (-25.60, -4.20) -- (-25.60, -4.30) -- (-26.10, -4.30) -- (-26.10, -4.60) -- (-24.30, -4.60) -- (-24.00, -4.60) -- (-24.00, -4.90) -- (-24.00, -4.90) -- (-24.50, -4.90) -- (-24.50, -4.90) -- (-24.70, -4.90) -- (-24.70, -4.90) -- (-17.60, -4.90) -- (-17.80, -4.90) -- (-17.80, -4.90) -- (-17.80, -5.30) -- (-17.80, -5.30) -- (-17.80, -4.90) -- (-18.10, -4.90) -- (-18.10, -5.40) -- (-18.10, -4.20) -- (-18.10, -4.20) -- (-26.40, -4.20) -- (-25.90, -4.20) -- (-26.10, -4.20) -- (-26.10, -3.90) -- (-26.00, -3.90) -- (-26.00, -4.30) -- (-35.50, -4.30) -- (-35.50, -4.30) -- (-35.50, 3.40) -- (-35.50, 3.40) -- (-35.50, 3.60) -- (-35.90, 3.60) -- (-31.40, 3.60) -- (-31.90, 3.60) -- (-31.90, 3.60) -- (-32.40, 3.60) -- (-32.40, 3.70) -- (-32.40, 3.70) -- (-32.20, 3.70) -- (-32.70, 3.70) -- (-32.70, 3.70) -- (-32.20, 3.70) -- (-32.20, 11.60) -- (-32.20, 11.60) -- (-37.90, 11.60) -- (-37.90, 11.60) -- (-37.40, 11.60) -- (-37.40, 16.20) -- (-37.40, 16.70) -- (-37.40, 19.70) -- (-37.10, 19.70) -- (-37.10, 20.10) -- (-37.30, 20.10) -- (-37.30, 30.10) -- (-37.00, 30.10) -- (-37.00, 29.60) -- (-37.50, 29.60) -- (-37.50, 33.00) -- (-37.10, 33.00) -- (-37.10, 32.70) -- (-37.10, 35.70) -- (-37.10, 35.30) -- (-37.10, 35.30) -- (-37.10, 35.10) -- (-42.20, 35.10) -- (-42.70, 35.10) -- (-46.80, 35.10) -- (-46.30, 35.10) -- (-46.30, 35.20) -- (-46.30, 35.20) -- (-46.30, 34.80) -- (-46.30, 44.50) -- (-46.30, 44.50) -- (-46.30, 44.40) -- (-46.30, 40.60) -- (-46.30, 40.90) -- (-46.00, 40.90) -- (-46.00, 40.90) -- (-46.00, 40.40) -- (-51.90, 40.40) -- (-51.90, 40.40) -- (-52.10, 40.40) -- (-52.10, 47.50) -- (-52.10, 47.50) -- (-52.10, 47.80) -- (-55.70, 47.80) -- (-55.70, 47.80) -- (-55.70, 47.70) -- (-55.70, 45.30) -- (-55.70, 45.20) -- (-55.70, 45.20) -- (-61.30, 45.20) -- (-61.30, 44.90) -- (-66.60, 44.90) -- (-66.50, 44.90) -- (-66.20, 44.90) -- (-74.00, 44.90) -- (-74.00, 44.90) -- (-74.00, 45.10) -- (-73.60, 45.10) -- (-73.60, 45.10) -- (-73.50, 45.10) -- (-73.50, 44.90) -- (-73.80, 44.90) -- (-73.80, 44.60) -- (-73.80, 38.20) -- (-73.90, 38.20) -- (-73.90, 38.20) -- (-73.90, 45.50) -- (-73.90, 54.70) -- (-73.90, 54.20) -- (-73.90, 54.20) -- (-74.30, 54.20) -- (-74.30, 54.70) -- (-74.10, 54.70) -- (-74.10, 54.70) -- (-73.60, 54.70) -- (-73.60, 54.90) -- (-73.30, 54.90) -- (-73.30, 54.60) -- (-73.30, 54.60) -- (-73.30, 54.20) -- (-73.50, 54.20) -- (-73.50, 54.60) -- (-73.00, 54.60) -- (-73.00, 54.60) -- (-73.00, 55.20) -- (-73.00, 55.20) -- (-73.20, 55.20) -- (-73.20, 55.30) -- (-73.20, 55.30) -- (-73.20, 56.90) -- (-73.20, 57.30) -- (-73.20, 57.30) -- (-66.70, 57.30) -- (-66.70, 57.30) -- (-66.70, 57.60) -- (-66.70, 57.60) -- (-67.20, 57.60) -- (-67.20, 57.60) -- (-67.20, 57.70) -- (-67.20, 53.60) -- (-67.40, 53.60) -- (-67.40, 53.50) -- (-67.70, 53.50) -- (-67.70, 46.60) -- (-68.20, 46.60) -- (-68.20, 47.00) -- (-68.20, 39.90) -- (-68.60, 39.90) -- (-68.60, 39.90) -- (-78.00, 39.90) -- (-78.10, 39.90) -- (-81.10, 39.90) -- (-81.30, 39.90) -- (-81.30, 40.10) -- (-87.80, 40.10) -- (-87.80, 40.10) -- (-87.80, 40.50) -- (-87.80, 40.50) -- (-87.70, 40.50) -- (-87.70, 40.50) -- (-87.50, 40.50) -- (-87.50, 40.50) -- (-87.50, 40.10) -- (-87.50, 40.10) -- (-87.10, 40.10) -- (-87.10, 40.10) -- (-86.60, 40.10) -- (-86.60, 39.80) -- (-93.90, 39.80) -- (-93.90, 40.20) -- (-94.30, 40.20) -- (-94.30, 40.00) -- (-93.90, 40.00) -- (-93.90, 40.00) -- (-93.90, 40.40) -- (-93.90, 30.40) -- (-93.90, 30.00) -- (-93.90, 30.00) -- (-93.60, 30.00) -- (-93.60, 30.30) -- (-93.60, 30.30) -- (-93.60, 30.40) -- (-94.00, 30.40) -- (-94.00, 30.10) -- (-94.00, 29.60) -- (-94.00, 25.00) -- (-94.00, 25.50) -- (-94.00, 25.50) -- (-94.00, 33.00) -- (-94.00, 32.50) -- (-94.00, 32.50) -- (-98.20, 32.50) -- (-98.20, 32.50) -- (-98.20, 32.50) -- (-98.40, 32.50) -- (-91.70, 32.50) -- (-91.90, 32.50) -- (-92.20, 32.50) -- (-91.90, 32.50) -- (-91.90, 32.50) -- (-92.20, 32.50) -- (-92.20, 39.70) -- (-92.20, 40.00) -- (-92.40, 40.00) -- (-92.40, 40.00) -- (-92.40, 40.40) -- (-93.60, 40.40) -- (-93.80, 40.40) -- (-95.80, 40.40) -- (-96.00, 40.40) -- (-96.50, 40.40) -- (-96.50, 40.90) -- (-97.00, 40.90) -- (-97.00, 40.90) -- (-97.20, 40.90) -- (-92.70, 40.90) -- (-93.10, 40.90) -- (-93.10, 40.90) -- (-92.80, 40.90) -- (-92.80, 40.90) -- (-92.80, 40.70) -- (-99.70, 40.70) -- (-99.70, 40.70) -- (-100.00, 40.70) -- (-100.00, 40.70) -- (-100.00, 41.20) -- (-99.70, 41.20) -- (-99.70, 40.40) -- (-99.70, 39.90) -- (-99.70, 39.90) -- (-99.70, 39.40) -- (-106.10, 39.40) -- (-106.10, 39.40) -- (-106.50, 39.40) -- (-106.50, 44.00) -- (-106.50, 44.00) -- (-106.80, 44.00) -- (-106.80, 44.10) -- (-106.20, 44.10) -- (-106.20, 44.50) -- (-106.20, 44.50) -- (-106.20, 40.70) -- (-106.20, 40.20) -- (-105.70, 40.20) -- (-105.70, 40.60) -- (-105.70, 40.60) -- (-105.80, 40.60) -- (-112.40, 40.60) -- (-112.40, 40.60) -- (-112.70, 40.60) -- (-112.70, 40.60) -- (-113.20, 40.60) -- (-113.20, 40.60) -- (-113.40, 40.60) -- (-113.40, 40.20) -- (-113.60, 40.20) -- (-113.60, 40.20) -- (-113.10, 40.20) -- (-113.10, 40.20) -- (-113.10, 39.70) -- (-113.10, 39.70) -- (-113.10, 39.60) -- (-113.10, 39.60) -- (-113.10, 39.80) -- (-113.60, 39.80) -- (-113.60, 39.50) -- (-113.90, 39.50) -- (-113.90, 39.50) -- (-113.70, 39.50) -- (-113.70, 39.50) -- (-113.70, 34.40) -- (-113.70, 34.40) -- (-113.70, 34.40) -- (-113.70, 34.70) -- (-114.10, 34.70) -- (-114.10, 34.80) -- (-114.50, 34.80) -- (-114.90, 34.80) -- (-114.90, 34.80) -- (-114.20, 34.80) -- (-114.20, 34.40) -- (-114.10, 34.40) -- (-114.10, 34.30) -- (-114.10, 34.30) -- (-114.10, 34.00) -- (-113.70, 34.00) -- (-113.70, 26.70) -- (-114.10, 26.70) -- (-114.10, 26.70) -- (-114.50, 26.70) -- (-114.10, 26.70) -- (-114.10, 26.70) -- (-113.60, 26.70) -- (-113.60, 26.50) -- (-113.30, 26.50) -- (-113.30, 26.50) -- (-105.60, 26.50) -- (-105.90, 26.50) -- (-105.90, 26.50) -- (-105.90, 26.00) -- (-106.30, 26.00) -- (-106.30, 25.70) -- (-105.90, 25.70) -- (-105.90, 25.70) -- (-105.90, 25.20) -- (-115.80, 25.20) -- (-115.40, 25.20) -- (-114.90, 25.20) -- (-114.90, 25.20) -- (-114.90, 25.40) -- (-114.90, 19.60) -- (-114.90, 19.60) -- (-114.70, 19.60) -- (-114.70, 19.70) -- (-115.10, 19.70) -- (-123.60, 19.70) -- (-124.00, 19.70) -- (-124.00, 19.90) -- (-123.70, 19.90) -- (-123.70, 19.90) -- (-123.30, 19.90) -- (-123.30, 19.90) -- (-123.30, 20.30) -- (-123.00, 20.30) -- (-129.40, 20.30) -- (-129.90, 20.30) -- (-129.90, 19.80) -- (-138.80, 19.80) -- (-141.70, 19.80) -- (-141.70, 19.80) -- (-141.70, 11.80) -- (-141.70, 11.90) -- (-141.70, 11.90) -- (-142.10, 11.90) -- (-142.10, 11.40) -- (-134.50, 11.40) -- (-134.00, 11.40) -- (-125.70, 11.40) -- (-125.50, 11.40) -- (-119.50, 11.40) -- (-119.80, 11.40) -- (-119.80, 11.80) -- (-119.90, 11.80) -- (-119.90, 11.80) -- (-119.90, 9.30) -- (-120.40, 9.30) -- (-120.40, 9.00) -- (-120.90, 9.00) -- (-120.90, 9.00) -- (-120.50, 9.00) -- (-120.50, 16.90) -- (-120.50, 16.80) -- (-121.00, 16.80) -- (-121.00, 21.00) -- (-121.30, 21.00) -- (-121.30, 21.60) -- (-120.80, 21.60) -- (-120.80, 21.60) -- (-120.80, 21.30) -- (-120.80, 21.30) -- (-120.80, 21.50) -- (-120.80, 21.50) -- (-128.80, 21.50) -- (-129.10, 21.50) -- (-129.10, 21.50) -- (-128.70, 21.50) -- (-128.70, 21.70) -- (-120.00, 21.70) -- (-120.50, 21.70) -- (-121.00, 21.70) -- (-121.00, 21.70) -- (-121.00, 21.70) -- (-121.30, 21.70) -- (-121.30, 21.70) -- (-128.20, 21.70) -- (-128.20, 21.70) -- (-128.20, 20.80) -- (-127.80, 20.80) -- (-127.80, 17.10) -- (-127.80, 17.10) -- (-127.80, 16.80) -- (-122.80, 16.80) -- (-122.80, 16.80) -- (-122.90, 16.80) -- (-122.90, 23.80) -- (-122.90, 24.30) -- (-122.90, 24.30) -- (-123.30, 24.30) -- (-123.30, 24.50) -- (-123.80, 24.50) -- (-125.70, 24.50) -- (-125.70, 24.90) -- (-125.90, 24.90) -- (-125.90, 25.00) -- (-126.30, 25.00) -- (-126.30, 25.00) -- (-126.30, 30.60) -- (-126.40, 30.60) -- (-126.40, 30.60) -- (-126.00, 30.60) -- (-126.00, 30.60) -- (-126.00, 30.10) -- (-126.00, 30.30) -- (-126.00, 30.30) -- (-126.00, 30.50) -- (-133.70, 30.50) -- (-133.60, 30.50) -- (-133.60, 30.50) -- (-133.60, 33.60) -- (-133.70, 33.60) -- (-133.70, 34.00) -- (-133.70, 34.00) -- (-133.90, 34.00) -- (-133.90, 34.00) -- (-134.00, 34.00) -- (-134.00, 33.80) -- (-133.70, 33.80) -- (-124.40, 33.80) -- (-124.40, 34.30) -- (-124.00, 34.30) -- (-120.10, 34.30) -- (-120.10, 33.90) -- (-120.40, 33.90) -- (-120.40, 33.90) -- (-120.40, 34.00) -- (-120.40, 34.00) -- (-120.40, 33.80) -- (-119.30, 33.80) -- (-109.80, 33.80) -- (-109.50, 33.80) -- (-109.50, 33.40) -- (-109.90, 33.40) -- (-109.90, 33.40) -- (-109.90, 27.80) -- (-109.90, 28.10) -- (-109.90, 26.50) -- (-109.90, 26.50) -- (-109.70, 26.50) -- (-109.70, 26.20) -- (-115.30, 26.20) -- (-115.70, 26.20) -- (-115.70, 26.30) -- (-115.60, 26.30) -- (-115.60, 26.80) -- (-115.60, 26.80) -- (-115.60, 35.40) -- (-115.60, 35.90) -- (-115.60, 35.90) -- (-115.60, 35.80) -- (-115.60, 35.40) -- (-115.60, 35.40) -- (-115.40, 35.40) -- (-115.40, 35.50) -- (-115.40, 38.30) -- (-114.90, 38.30) -- (-114.90, 38.30) -- (-114.90, 29.00) -- (-114.90, 29.00) -- (-106.50, 29.00) -- (-106.00, 29.00) -- (-106.00, 29.00) -- (-105.60, 29.00) -- (-108.10, 29.00) -- (-108.10, 29.00) -- (-107.60, 29.00) -- (-107.60, 29.20) -- (-107.60, 29.20) -- (-106.30, 29.20) -- (-106.30, 29.60) -- (-97.20, 29.60) -- (-96.90, 29.60) -- (-96.20, 29.60) -- (-96.20, 29.50) -- (-96.70, 29.50) -- (-96.80, 29.50) -- (-90.10, 29.50) -- (-90.10, 29.10) -- (-90.60, 29.10) -- (-90.60, 29.10) -- (-90.60, 29.10) -- (-90.20, 29.10) -- (-90.20, 28.90) -- (-90.20, 28.90) -- (-90.20, 28.70) -- (-85.70, 28.70) -- (-85.70, 29.10) -- (-85.40, 29.10) -- (-85.40, 29.50) -- (-80.10, 29.50) -- (-80.10, 29.80) -- (-79.80, 29.80) -- (-79.80, 29.40) -- (-79.80, 29.40) -- (-79.80, 29.30) -- (-79.80, 24.10) -- (-79.80, 24.30) -- (-79.80, 23.80) -- (-79.60, 23.80) -- (-79.60, 24.10) -- (-79.60, 24.00) -- (-79.60, 24.00) -- (-79.60, 24.30) -- (-79.40, 24.30) -- (-79.40, 27.40) -- (-79.40, 27.20) -- (-79.40, 26.70) -- (-79.40, 26.90) -- (-79.40, 27.40) -- (-79.80, 27.40) -- (-79.80, 27.40) -- (-79.80, 27.40) -- (-79.90, 27.40) -- (-79.90, 24.00) -- (-80.10, 24.00) -- (-80.10, 24.00) -- (-79.90, 24.00) -- (-79.90, 24.00) -- (-79.90, 24.50) -- (-80.10, 24.50) -- (-80.10, 24.50) -- (-80.10, 24.70) -- (-80.10, 24.50) -- (-80.10, 24.80) -- (-75.30, 24.80) -- (-75.30, 24.60) -- (-75.30, 24.60) -- (-75.30, 32.70) -- (-75.30, 32.90) -- (-75.30, 34.50) -- (-75.70, 34.50) -- (-75.70, 38.50) -- (-75.70, 38.50) -- (-75.70, 38.80) -- (-75.70, 38.80) -- (-75.70, 39.00) -- (-75.70, 39.00) -- (-75.20, 39.00) -- (-75.20, 39.80) -- (-75.20, 40.40) -- (-75.20, 40.40) -- (-75.20, 40.10) -- (-75.70, 40.10) -- (-75.80, 40.10) -- (-75.80, 40.10) -- (-75.80, 38.30) -- (-75.80, 38.00) -- (-75.80, 38.00) -- (-73.90, 38.00) -- (-73.90, 38.00) -- (-73.90, 33.40) -- (-73.90, 29.70) -- (-73.90, 29.70) -- (-73.90, 30.00) -- (-74.30, 30.00) -- (-74.00, 30.00) -- (-76.80, 30.00) -- (-76.50, 30.00) -- (-76.50, 30.50) -- (-76.50, 30.50) -- (-76.50, 30.10) -- (-76.40, 30.10) -- (-76.40, 27.30) -- (-76.40, 27.30) -- (-76.40, 27.80) -- (-76.40, 27.80) -- (-76.40, 27.90) -- (-76.40, 27.90) -- (-76.10, 27.90) -- (-76.10, 27.80) -- (-76.10, 27.80) -- (-76.10, 31.00) -- (-76.10, 31.00) -- (-76.10, 31.40) -- (-73.90, 31.40) -- (-73.90, 31.40) -- (-73.90, 30.90) -- (-73.50, 30.90) -- (-73.50, 30.90) -- (-66.50, 30.90) -- (-66.90, 30.90) -- (-63.00, 30.90) -- (-63.00, 30.50) -- (-63.00, 30.50) -- (-63.00, 30.60) -- (-63.00, 30.60) -- (-63.60, 30.60) -- (-63.60, 30.60) -- (-63.60, 21.40) -- (-63.60, 21.40) -- (-63.60, 21.90) -- (-63.60, 21.90) -- (-63.60, 21.90) -- (-63.60, 22.40) -- (-63.40, 22.40) -- (-63.40, 22.40) -- (-62.90, 22.40) -- (-62.90, 22.40) -- (-62.90, 12.90) -- (-62.90, 13.30) -- (-62.80, 13.30) -- (-62.80, 5.60) -- (-62.80, 5.90) -- (-62.80, 5.90) -- (-62.80, 5.70) -- (-63.00, 5.70) -- (-63.00, 12.80) -- (-63.00, 18.70) -- (-63.00, 19.00) -- (-63.00, 20.00) -- (-62.60, 20.00) -- (-62.60, 20.00) -- (-62.60, 20.50) -- (-63.50, 20.50) -- (-63.50, 20.50) -- (-63.60, 20.50) -- (-63.60, 20.00) -- (-64.10, 20.00) -- (-57.00, 20.00) -- (-56.90, 20.00) -- (-53.40, 20.00) -- (-53.40, 20.00) -- (-53.40, 15.50) -- (-53.40, 15.60) -- (-53.40, 10.20);
\end{tikzpicture}
\end{document}
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[red,thick] (0,0) circle (2);
\draw[blue,thick] (-13.9130, 12.9280) circle (2);
\draw[thick] (0.0000, 0.0000)--(0.0000, 0.0000)--(0.0000, 0.0000)--(0.0000, 0.0000)--(-0.0300, 0.0120)--(-0.0300, 0.0120)--(-0.0300, 0.0120)--(-0.0300, 0.0120)--(-0.4300, -0.0880)--(-0.4300, -0.0880)--(-0.4300, -0.0880)--(-0.3750, -0.0770)--(-0.3750, -0.0770)--(-0.3750, -0.0770)--(0.3000, -0.0770)--(0.3000, -0.0770)--(0.3000, -0.0770)--(0.8280, 0.1870)--(0.8280, 0.1870)--(0.8280, 0.1870)--(0.8140, 0.2030)--(0.8140, 0.2030)--(0.8140, 0.2030)--(0.8140, 0.2030)--(1.5700, 0.5390)--(1.5700, 0.5390)--(1.5700, 0.5390)--(1.5700, 0.5390)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(2.0600, 0.7350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(0.9600, 0.3350)--(1.2300, 0.0350)--(1.2300, 0.0350)--(1.5900, -0.1650)--(1.5900, -0.1650)--(1.5900, -0.1650)--(1.5900, -0.1650)--(0.7440, 0.6810)--(0.7440, 0.6810)--(0.7440, 0.6810)--(0.3780, 0.1320)--(0.3780, 0.1320)--(-0.0900, -0.8820)--(-0.0900, -0.8820)--(-0.0900, -0.8820)--(-0.0900, -0.8820)--(-0.0340, -0.6720)--(-0.0340, -0.6720)--(-1.5340, -0.2720)--(-1.5340, -0.2720)--(-1.5940, -0.4970)--(-1.5940, -0.4970)--(-1.5940, -0.4970)--(-0.4390, -0.4970)--(-0.4390, -0.4970)--(0.4310, -0.6130)--(0.4310, -0.6130)--(0.4310, -0.6130)--(0.4310, -1.2280)--(0.4310, -1.2280)--(0.4310, -1.2280)--(0.4310, -1.2280)--(0.4310, -0.4090)--(0.4310, -0.4090)--(0.4310, -0.0970)--(0.4310, -0.0970)--(0.4310, -0.0970)--(0.1390, 0.1220)--(0.1390, 0.1220)--(-0.0610, 0.0720)--(-0.0610, 0.0720)--(-0.0610, 0.0720)--(0.0090, -0.4180)--(0.0090, -0.4180)--(0.0090, -0.4180)--(0.0090, -0.4180)--(0.0090, -0.3180)--(0.0090, -0.3180)--(0.0090, -0.3180)--(0.0090, -0.3180)--(0.0090, -0.3180)--(0.0090, -0.3180)--(0.3240, -0.4440)--(0.3240, -0.4440)--(0.3240, -0.4440)--(0.2640, -0.2940)--(0.2640, -0.2940)--(0.2640, -0.2940)--(-0.3440, -0.4460)--(-0.3440, -0.4460)--(-0.3440, -0.4460)--(-0.3440, -0.4460)--(-0.3440, -0.4460)--(-0.2840, -0.6860)--(-0.2840, -0.6860)--(-0.2600, -0.8140)--(-0.2600, -0.8140)--(-1.0120, -0.9550)--(-1.0120, -0.9550)--(-1.0120, -0.9550)--(-1.0120, -0.9550)--(0.1880, -0.7300)--(1.0840, -0.5620)--(1.0840, -0.5620)--(0.9790, -0.0020)--(0.9790, -0.0020)--(0.9790, -0.0020)--(0.9790, -0.0020)--(0.9780, 0.0140)--(0.9780, 0.0140)--(0.8020, 0.7180)--(0.8020, 0.7180)--(0.8020, 0.7180)--(-0.6860, 0.1600)--(-0.6860, 0.1600)--(-0.6860, 0.1600)--(-1.9310, 0.0770)--(-2.3510, 0.0490)--(-2.3510, 0.0490)--(-2.3510, 0.0490)--(-2.3510, 0.0490)--(-2.3510, 0.0490)--(-2.3510, 0.0490)--(-2.3510, 0.9610)--(-2.3510, 0.9610)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.3510, 2.3910)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-2.5310, 1.9230)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-3.0280, -0.3490)--(-2.6800, -0.4210)--(-2.6800, -0.4210)--(-2.1820, 1.9860)--(-2.1820, 1.9860)--(-2.1820, 1.9860)--(-2.1820, 1.9860)--(-2.1820, 1.9860)--(-2.1820, 1.9860)--(-1.2320, 4.6460)--(-1.2320, 4.6460)--(0.9240, 3.8760)--(0.9240, 3.8760)--(0.9240, 3.8760)--(0.9240, 3.8760)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.2940, 2.7060)--(0.4040, 2.8610)--(0.4040, 2.8610)--(0.4040, 2.8610)--(3.2480, 1.1230)--(3.2480, 1.1230)--(4.5020, 3.1750)--(4.5020, 3.1750)--(4.5020, 3.1750)--(6.3880, 2.1630)--(6.3880, 2.1630)--(7.6180, 1.6530)--(7.6180, 1.6530)--(7.6180, 1.6530)--(7.6180, 1.6530)--(11.8180, 0.3530)--(11.8180, 0.3530)--(11.8180, 0.3530)--(11.8180, 0.3530)--(13.1780, -0.2590)--(13.1780, -0.2590)--(13.1780, -0.2590)--(14.4980, -0.8890)--(14.4980, -0.8890)--(14.4980, -0.8890)--(14.4980, -0.8890)--(15.7730, 1.2530)--(15.7730, 1.2530)--(16.5930, 2.9750)--(16.5930, 2.9750)--(16.5930, 2.9750)--(16.5930, 2.9750)--(16.5930, 2.9750)--(20.7640, 0.1620)--(20.7640, 0.1620)--(20.7640, 0.1620)--(19.1300, 1.2260)--(19.1300, 1.2260)--(19.1300, 1.2260)--(19.1300, 1.2260)--(19.1300, 1.2260)--(20.9590, 3.2910)--(20.9590, 3.2910)--(20.9590, 3.2910)--(23.3020, 1.0900)--(23.3020, 1.0900)--(23.3020, 1.0900)--(24.4180, 2.3860)--(24.4180, 2.3860)--(24.4180, 2.3860)--(23.5540, 3.1060)--(23.5540, 3.1060)--(23.5540, 3.1060)--(25.1780, 5.1220)--(25.1780, 5.1220)--(26.7150, 6.8710)--(26.7150, 6.8710)--(26.7150, 6.8710)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(29.2890, 9.4450)--(27.1770, 10.9810)--(27.1770, 10.9810)--(27.1770, 10.9810)--(29.6590, 9.2290)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.7870, 7.0210)--(32.9910, 6.8650)--(32.9910, 6.8650)--(32.9910, 6.8650)--(32.9910, 6.8650)--(32.9910, 6.8650)--(33.5190, 6.4170)--(33.5190, 6.4170)--(33.5190, 6.4170)--(31.9590, 4.2720)--(31.9590, 4.2720)--(31.9590, 4.2720)--(31.9590, 4.2720)--(31.9590, 4.2720)--(31.9590, 4.2720)--(31.9590, 4.2720)--(30.6060, 5.6250)--(30.6060, 5.6250)--(30.6060, 5.6250)--(30.6060, 5.6250)--(27.9840, 7.8330)--(27.9840, 7.8330)--(27.9840, 7.8330)--(24.9310, 10.3890)--(24.9310, 10.3890)--(24.9310, 10.3890)--(28.3150, 14.8070)--(28.3150, 14.8070)--(29.3650, 16.2170)--(29.3650, 16.2170)--(29.3650, 16.2170)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(31.5100, 19.4020)--(34.0650, 22.7600)--(34.0650, 22.7600)--(34.0650, 22.7600)--(34.0650, 22.7600)--(34.0650, 22.7600)--(34.0650, 22.7600)--(34.0650, 22.7600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(29.2650, 26.6600)--(27.0110, 27.8100)--(27.0110, 27.8100)--(27.0110, 27.8100)--(30.6860, 25.5600)--(30.6860, 25.5600)--(30.6860, 25.5600)--(32.1560, 27.6180)--(32.1560, 27.6180)--(32.1560, 27.6180)--(32.1560, 27.6180)--(29.6770, 24.3350)--(29.6770, 24.3350)--(29.6770, 24.3350)--(29.6770, 24.3350)--(29.6770, 24.3350)--(29.6770, 24.3350)--(32.9890, 21.5270)--(32.9890, 21.5270)--(32.9890, 21.5270)--(32.9890, 21.5270)--(32.9890, 21.5270)--(33.4210, 22.1030)--(33.4210, 22.1030)--(34.1010, 23.0630)--(34.1010, 23.0630)--(34.2610, 23.3030)--(34.2610, 23.3030)--(34.2610, 23.3030)--(34.2610, 23.3030)--(34.2610, 23.3030)--(32.9560, 20.9180)--(32.9560, 20.9180)--(32.9560, 20.9180)--(32.9560, 20.9180)--(32.9560, 20.9180)--(32.9560, 20.9180)--(35.2330, 24.6440)--(35.2330, 24.6440)--(35.2330, 24.6440)--(35.2330, 24.6440)--(35.2330, 24.6440)--(35.2330, 24.6440)--(34.8490, 24.9480)--(34.8490, 24.9480)--(34.8490, 24.9480)--(34.8490, 24.9480)--(36.9610, 27.7000)--(36.9610, 27.7000)--(36.9610, 27.7000)--(38.7550, 26.1820)--(38.7550, 26.1820)--(38.7550, 26.1820)--(38.7550, 26.1820)--(38.5390, 25.9540)--(38.5390, 25.9540)--(38.5390, 25.9540)--(37.2470, 27.3220)--(37.0770, 27.5020)--(37.0770, 27.5020)--(37.0770, 27.5020)--(37.0770, 27.5020)--(37.0770, 27.5020)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(39.6510, 29.4160)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.5800, 32.0170)--(38.1950, 31.7860)--(38.1950, 31.7860)--(38.1950, 31.7860)--(38.1950, 31.7860)--(38.1950, 31.7860)--(38.0810, 31.9480)--(38.0810, 31.9480)--(35.5990, 35.8900)--(35.5990, 35.8900)--(35.5990, 35.8900)--(35.5990, 35.8900)--(35.3670, 35.7380)--(35.3670, 35.7380)--(35.3670, 35.7380)--(35.3670, 35.7380)--(35.3670, 35.7380)--(35.3670, 35.7380)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(31.0550, 33.4280)--(37.6880, 35.9030)--(37.6880, 35.9030)--(37.6880, 35.9030)--(37.6880, 35.9030)--(37.6880, 35.9030)--(36.2380, 40.4270)--(36.2380, 40.4270)--(36.2380, 40.4270)--(36.2380, 40.4270)--(36.2380, 40.4270)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(42.6980, 42.6370)--(47.6900, 44.4290)--(47.6900, 44.4290)--(47.6900, 44.4290)--(54.1870, 46.4760)--(56.3040, 47.1430)--(56.3040, 47.1430)--(54.4640, 52.9830)--(54.4640, 52.9830)--(54.4640, 52.9830)--(54.4640, 52.9830)--(54.4640, 52.9830)--(48.5360, 50.8550)--(48.5360, 50.8550)--(42.4770, 48.5310)--(42.4770, 48.5310)--(38.2170, 46.8510)--(38.2170, 46.8510)--(38.2170, 46.8510)--(38.2170, 46.8510)--(38.2170, 46.8510)--(37.6170, 48.7260)--(37.6170, 48.7260)--(37.6170, 48.7260)--(37.6170, 48.7260)--(37.6170, 48.7260)--(37.6170, 48.7260)--(40.6190, 43.0380)--(40.6190, 43.0380)--(40.6190, 43.0380)--(42.0050, 39.9720)--(42.0050, 39.9720)--(42.1850, 39.5340)--(42.1850, 39.5340)--(42.1850, 39.5340)--(42.1850, 39.5340)--(42.1850, 39.5340)--(42.1850, 39.5340)--(42.1850, 39.5340)--(48.1850, 42.0940)--(48.1850, 42.0940)--(48.1850, 42.0940)--(48.1850, 42.0940)--(48.1850, 42.0940)--(42.2690, 39.4840)--(42.2690, 39.4840)--(42.2690, 39.4840)--(42.2690, 39.4840)--(42.2690, 39.4840)--(42.2690, 39.4840)--(42.2690, 39.4840)--(47.8580, 41.5540)--(47.8580, 41.5540)--(47.5880, 42.2830)--(47.5880, 42.2830)--(46.6260, 45.2800)--(46.6260, 45.2800)--(46.6260, 45.2800)--(42.5760, 43.8300)--(42.5760, 43.8300)--(42.5760, 43.8300)--(44.5360, 38.1600)--(44.5360, 38.1600)--(44.5360, 38.1600)--(44.5360, 38.1600)--(44.5360, 38.1600)--(44.5360, 38.1600)--(45.8090, 38.7300)--(45.8090, 38.7300)--(45.8090, 38.7300)--(45.8090, 38.7300)--(45.8090, 38.7300)--(45.8090, 38.7300)--(47.7690, 35.3140)--(47.7690, 35.3140)--(47.7690, 35.3140)--(47.7690, 35.3140)--(47.7690, 35.3140)--(47.7690, 35.3140)--(47.8370, 35.1740)--(47.8370, 35.1740)--(47.8370, 35.1740)--(53.2270, 37.9460)--(53.2270, 37.9460)--(53.2270, 37.9460)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(54.3430, 35.7450)--(48.4840, 32.3040)--(48.4840, 32.3040)--(48.4840, 32.3040)--(46.1830, 31.0560)--(46.1830, 31.0560)--(46.1830, 31.0560)--(46.1830, 31.0560)--(46.1830, 31.0560)--(46.1830, 31.0560)--(46.1830, 31.0560)--(45.5120, 30.6380)--(39.7170, 27.0280)--(39.7170, 27.0280)--(39.7170, 27.0280)--(39.7170, 27.0280)--(39.7170, 27.0280)--(37.3650, 30.5000)--(37.3650, 30.5000)--(36.6930, 31.5400)--(36.6930, 31.5400)--(36.6930, 31.5400)--(36.6930, 31.5400)--(40.4450, 33.7240)--(40.4450, 33.7240)--(40.4450, 33.7240)--(40.4450, 33.7240)--(40.4450, 33.7240)--(40.4450, 33.7240)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(44.3150, 28.2200)--(45.7710, 26.5960)--(45.7710, 26.5960)--(45.7710, 26.5960)--(40.4700, 31.9900)--(40.4700, 31.9900)--(35.5980, 27.2020)--(35.5980, 27.2020)--(35.5980, 27.2020)--(35.5980, 27.2020)--(37.0230, 28.6270)--(37.0230, 28.6270)--(37.0230, 28.6270)--(37.0230, 28.6270)--(37.0230, 28.6270)--(36.2560, 27.9510)--(36.2560, 27.9510)--(30.8870, 23.5830)--(30.8870, 23.5830)--(30.4950, 23.2470)--(30.4950, 23.2470)--(30.4950, 23.2470)--(30.4950, 23.2470)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(26.3410, 19.9640)--(23.2360, 17.3090)--(23.2360, 17.3090)--(23.2360, 17.3090)--(23.2360, 17.3090)--(19.7380, 14.6060)--(19.7380, 14.6060)--(19.7380, 14.6060)--(19.7380, 14.6060)--(19.7380, 14.6060)--(19.7380, 14.6060)--(17.0340, 17.8300)--(17.0340, 17.8300)--(17.0340, 17.8300)--(17.0340, 17.8300)--(17.0340, 17.8300)--(16.9840, 17.8920)--(16.9840, 17.8920)--(16.9840, 17.8920)--(16.9840, 17.8920)--(18.5960, 16.0630)--(18.5960, 16.0630)--(18.5960, 16.0630)--(18.5960, 16.0630)--(18.8560, 15.7430)--(18.8560, 15.7430)--(18.8560, 15.7430)--(18.8560, 15.7430)--(18.8560, 15.7430)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(17.1900, 17.9190)--(14.3100, 15.3750)--(14.3100, 15.3750)--(14.3100, 15.3750)--(18.7650, 10.5150)--(18.7650, 10.5150)--(19.6450, 9.5870)--(19.6450, 9.5870)--(21.6850, 7.2670)--(21.6850, 7.2670)--(21.6850, 7.2670)--(21.6850, 7.2670)--(21.6850, 7.2670)--(21.6850, 7.2670)--(21.6850, 7.2670)--(22.1410, 6.8030)--(22.4830, 6.4550)--(22.4830, 6.4550)--(22.4830, 6.4550)--(22.4830, 6.4550)--(22.4830, 6.4550)--(22.4830, 6.4550)--(21.4030, 7.6070)--(21.4030, 7.6070)--(21.4030, 7.6070)--(20.2440, 6.4670)--(20.2440, 6.4670)--(17.4840, 9.2730)--(15.2640, 11.5300)--(15.2640, 11.5300)--(15.2640, 11.5300)--(15.2640, 11.5300)--(15.2640, 11.5300)--(16.9440, 13.2940)--(16.9440, 13.2940)--(16.9440, 13.2940)--(16.9440, 13.2940)--(16.9440, 13.2940)--(16.9440, 13.2940)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(15.0680, 14.9460)--(16.9880, 13.0900)--(16.9880, 13.0900)--(16.9880, 13.0900)--(15.7120, 11.8580)--(15.7120, 11.8580)--(15.7120, 11.8580)--(15.7120, 11.8580)--(15.7120, 11.8580)--(11.3020, 7.6580)--(11.3020, 7.6580)--(8.6890, 5.3180)--(8.6890, 5.3180)--(8.6890, 5.3180)--(8.6890, 5.3180)--(8.6890, 5.3180)--(9.0850, 5.7020)--(9.0850, 5.7020)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(3.1970, 11.7740)--(-2.8830, 17.7590)--(-2.8830, 17.7590)--(-2.8830, 17.7590)--(-7.7340, 22.9180)--(-7.7340, 22.9180)--(-7.7340, 22.9180)--(-7.7340, 22.9180)--(-7.7340, 22.9180)--(-3.4030, 17.8060)--(0.1960, 13.5580)--(0.1960, 13.5580)--(0.8060, 12.8680)--(0.8060, 12.8680)--(0.8060, 12.8680)--(0.8060, 12.8680)--(1.4270, 13.4980)--(1.4270, 13.4980)--(1.4270, 13.4980)--(1.4270, 13.4980)--(1.4270, 13.4980)--(-3.8980, 8.1730)--(-3.8980, 8.1730)--(-6.4880, 5.5480)--(-6.4880, 5.5480)--(-9.8630, 8.8780)--(-9.8630, 8.8780)--(-13.9130, 12.9280);
\end{tikzpicture}
\end{document}
package aoc2020
import aoc2020.lib._
import Vectors._
type Pos = Vec2D[Int]
import aoc2020.lib.Vectors._
def day12(input: List[String]): String =
val directions = input.map(s => (s(0), s.substr(1).toInt))
val finalPos1 = moveShip(directions)
val part1 = s"Final position: ${finalPos1.pos}, facing ${finalPos1.dir.str}\nManhattan: ${finalPos1.pos.manhattan}"
val finalPos2 = moveWaypoint(directions)
val part2 = s"Final position: ${finalPos2.ship}, waypoint at ${finalPos2.waypoint}\nManhattan: ${finalPos2.ship.manhattan}"
part1 + "\n\n" + part2
case class Ship(dir: Dir, pos: Pos)
case class WaypointShip(ship: Pos, waypoint: Pos)
def moveShip(directions: List[(Char, Int)]): Ship =
directions.foldLeft(Ship(East, Vec2D(0,0)))((ship, command) => {
command match {
case ('L', deg) => ship.copy(dir = ship.dir + deg)
case ('R', deg) => ship.copy(dir = ship.dir - deg)
case ('F', dist) => ship.copy(pos = ship.pos.move(ship.dir, dist))
case (dir, dist) => ship.copy(pos = ship.pos.move(dir.cardinal, dist))
}
})
def moveWaypoint(directions: List[(Char, Int)]): WaypointShip =
directions.foldLeft(WaypointShip(Vec2D(0,0), Vec2D(10,1)))((state, command) => {
command match {
case ('L', deg) => state.copy(waypoint = state.waypoint.rot(deg))
case ('R', deg) => state.copy(waypoint = state.waypoint.rot(-deg))
case ('F', dist) => state.copy(ship = state.ship + state.waypoint * dist)
case (dir, dist) => state.copy(waypoint = state.waypoint.move(dir.cardinal, dist))
}
val directions = Instruction.parse(input)
val path1 = Ship(East, Vec2D(0,0)).path(directions)
val path2 = WaypointShip(Vec2D(0,0), Vec2D(10,1)).path(directions)
// Output
val path1Tikz = tikzPath(path1.map(_.pos), opts = "thick")
val path2Tikz = tikzPath(path2.map(_.ship), scale = 0.001, opts = "thick")
val finalPos1 = path1.last
val finalPos2 = path2.last
s""" Final position (direct orders): ${finalPos1.pos} (L₁: ${finalPos1.pos.manhattan}), facing ${finalPos1.look.str}
| Final position (waypoint): ${finalPos2.ship} (L₁: ${finalPos2.ship.manhattan}), waypoint at ${finalPos2.nav}
|
| Tikz path for direct orders:
| $path1Tikz
|
| Tikz path for waypoint navigation:
| $path2Tikz
|""".stripMargin
enum Instruction {
case Rot(deg: Dir)
case Move(dir: Dir, dist: Int)
case Forward(dist: Int)
}
import Instruction._
object Instruction {
def parse(input: List[String]): List[Instruction] =
input.map(s => (s(0), s.substr(1).toInt) match {
case ('L', deg) => Rot(Dir(deg))
case ('R', deg) => Rot(Dir(-deg))
case ('F', dist) => Forward(dist)
case (dir, dist) => Move(dir.cardinal, dist)
})
}
trait Nav[T] { self: T =>
def follow(directions: List[Instruction]): T =
directions.foldLeft(self)(_ follow _)
object Vectors {
import scala.Numeric.Implicits.given
opaque type Vec2D[T] = (T, T)
opaque type Dir = Int
val East: Dir = 0
val North: Dir = 90
val West: Dir = 180
val South: Dir = 270
extension (c: Char)
def cardinal: Dir = c match {
case 'E' => East
case 'N' => North
case 'W' => West
case 'S' => South
}
extension (dir: Dir)
def +(deg: Int): Dir = (dir + deg) % 360
def -(deg: Int): Dir = ((dir - deg) % 360 + 360) % 360
def unary_- : Dir = 360 - dir
def str: String = dir match {
case East => "East"
case North => "North"
case West => "West"
case South => "South"
}
extension [T: Numeric](v: Vec2D[T])
def +(w: Vec2D[T]): Vec2D[T] = (v._1 + w._1, v._2 + w._2)
def -(w: Vec2D[T]): Vec2D[T] = (v._1 - w._1, v._2 - w._2)
def *(x: T): Vec2D[T] = (v._1 * x, v._2 * x)
def rot(deg: Int): Vec2D[T] = (deg % 360 + 360) % 360 match {
case 90 => (-v._2, v._1)
case 180 => (-v._1, -v._2)
case 270 => (v._2, -v._1)
case 0 => v
}
def path(directions: List[Instruction]): List[T] =
directions.scanLeft(self)(_ follow _)
def left(deg: Int): Vec2D[T] = repeat[Vec2D[T]](deg / 90)(_.rotLeft)(v)
def right(deg: Int): Vec2D[T] = repeat[Vec2D[T]](deg / 90)(_.rotRight)(v)
def follow(command: Instruction): T & Nav[T]
}
def rotLeft: Vec2D[T] = (-v._2, v._1)
def rotRight: Vec2D[T] = (v._2, -v._1)
/* Part 1: Navigate by interpreting instructions as relative ship movements */
case class Ship(look: Dir, pos: Vec2D[Int]) extends Nav[Ship] {
def rotate(deg: Dir) = copy(look = look + deg)
def move(dir: Dir, dist: Int) = copy(pos = pos.move(dir, dist))
def move(dir: Dir, dist: T): Vec2D[T] = dir match {
case North => (v._1, v._2 + dist)
case South => (v._1, v._2 - dist)
case East => (v._1 + dist, v._2)
case West => (v._1 - dist, v._2)
}
def manhattan: T = v._1.abs + v._2.abs
def follow(command: Instruction): Ship = command match {
case Rot(deg) => rotate(deg)
case Forward(dist) => move(look, dist)
case Move(dir, dist) => move(dir, dist)
}
}
def Vec2D[T](x: T, y: T): Vec2D[T] = (x,y)
/* Part 2: Navigate by interpreting instructions as moving a waypoint relative
* to the ship */
case class WaypointShip(ship: Vec2D[Int], nav: Vec2D[Int]) extends Nav[WaypointShip] {
def rotate(deg: Dir) = copy(nav = nav.rot(deg))
def move(dir: Dir, dist: Int) = copy(nav = nav.move(dir, dist))
def forward(factor: Int) = copy(ship = ship + nav * factor)
def follow(command: Instruction): WaypointShip = command match {
case Rot(deg) => rotate(deg)
case Forward(dist) => forward(dist)
case Move(dir, dist) => move(dir, dist)
}
}
def tikzPath(points: List[Vec2D[Int]], scale: Double = 0.1, opts: String = ""): String =
points.map(p => f"(${p.x * scale}%.4f, ${p.y * scale}%.4f)").mkString(s"\\draw[$opts] ","--", ";")
}
package aoc2020.lib
object Vectors {
import scala.Numeric.Implicits.given
opaque type Vec2D[T] = (T, T)
opaque type Dir = Int
val East: Dir = 0
val North: Dir = 90
val West: Dir = 180
val South: Dir = 270
extension (c: Char)
def cardinal: Dir = c match {
case 'E' => East
case 'N' => North
case 'W' => West
case 'S' => South
}
extension (dir: Dir)
def +(deg: Int|Dir): Dir = (dir + deg) % 360
def -(deg: Int|Dir): Dir = ((dir - deg) % 360 + 360) % 360
def unary_- : Dir = 360 - dir
def str: String = dir match {
case East => "East"
case North => "North"
case West => "West"
case South => "South"
}
def Dir(deg: Int): Dir = (deg % 360 + 360) % 360
extension [T: Numeric](v: Vec2D[T])
def +(w: Vec2D[T]): Vec2D[T] = (v._1 + w._1, v._2 + w._2)
def -(w: Vec2D[T]): Vec2D[T] = (v._1 - w._1, v._2 - w._2)
def *(x: T): Vec2D[T] = (v._1 * x, v._2 * x)
def x: T = v._1
def y: T = v._2
def rot(deg: Dir): Vec2D[T] = deg match {
case 90 => (-v._2, v._1)
case 180 => (-v._1, -v._2)
case 270 => (v._2, -v._1)
case 0 => v
}
def left(deg: Int): Vec2D[T] = repeat[Vec2D[T]](deg / 90)(_.rotLeft)(v)
def right(deg: Int): Vec2D[T] = repeat[Vec2D[T]](deg / 90)(_.rotRight)(v)
def rotLeft: Vec2D[T] = (-v._2, v._1)
def rotRight: Vec2D[T] = (v._2, -v._1)
def move(dir: Dir, dist: T): Vec2D[T] = dir match {
case North => (v._1, v._2 + dist)
case South => (v._1, v._2 - dist)
case East => (v._1 + dist, v._2)
case West => (v._1 - dist, v._2)
}
def manhattan: T = v._1.abs + v._2.abs
def Vec2D[T](x: T, y: T): Vec2D[T] = (x,y)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment