From e89a78b0539f89e5276ce18ba0c88ee87863a778 Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Wed, 9 Dec 2020 01:40:12 +0000 Subject: [PATCH] ZAP! Day 10. --- day10/common.sh | 4 +- day10/zap.sh | 138 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 day10/zap.sh diff --git a/day10/common.sh b/day10/common.sh index 86979ed..db5c6b9 100644 --- a/day10/common.sh +++ b/day10/common.sh @@ -4,8 +4,8 @@ get_vector() { local x2=$3 local y2=$4 - x_diff=$(($x1 - $x2)) - y_diff=$(($y1 - $y2)) + x_diff=$(($x2 - $x1)) + y_diff=$(($y2 - $y1)) echo "$x_diff,$y_diff" } diff --git a/day10/zap.sh b/day10/zap.sh new file mode 100644 index 0000000..eae98d2 --- /dev/null +++ b/day10/zap.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +basedir=$(dirname $(readlink -f $BASH_SOURCE)) +. $basedir/common.sh + +our_asteroid=26,29 + +declare -A asteroids +declare -A asteroid_angles + +exec 3