Skip to content

Instantly share code, notes, and snippets.

View rhowe's full-sized avatar
💭
Just being

Russell Howe rhowe

💭
Just being
View GitHub Profile
@rhowe
rhowe / 5-2.sh
Created December 5, 2019 13:31
AOC2019day5part2
#!/bin/bash
set -eu
IFS=, read -r -a ram < "$1"
getval() {
case $1 in
0) echo "${ram[$2]}" ;;
1) echo "$2" ;;
@rhowe
rhowe / 3-2.sh
Last active December 5, 2019 18:55
AOC2019day3part2
#!/bin/bash
set -eu
set -o pipefail
xorigin=1000
yorigin=1000
wires=()
@rhowe
rhowe / 6.sh
Created December 6, 2019 18:49
AOC2019day6part1
#!/bin/bash
set -eu
set -o pipefail
orrery=/dev/shm/orrery
cd "$(dirname "$0")"
rm -rf "$orrery"
mkdir "$orrery"
@rhowe
rhowe / 6-2.sh
Last active December 6, 2019 19:06
AOC2019day6part2
#!/bin/bash
set -eu
set -o pipefail
orrery=/dev/shm/orrery
rm -rf "$orrery"
mkdir "$orrery"
@rhowe
rhowe / 7-1.sh
Created December 7, 2019 07:38
AOC2019day7part1
#!/bin/bash
set -eu
getval() {
case $1 in
0) echo "${ram[$2]}" ;;
1) echo "$2" ;;
esac
}
#!/bin/bash
# This program has some kind of deadlock/race condition
# There are some hacks to let you rerun it and make continual progress so you can:
# while true; do ./7.sh input & sleep 10; kill %1; done
set -eu
getval() {
case $1 in
@rhowe
rhowe / 8.sh
Created December 8, 2019 10:02
AOC2019day8part1
#!/bin/bash
set -eu
input=$(<"$1")
layers=()
width=25
height=6
area=$((width * height))
@rhowe
rhowe / 8-2.sh
Created December 8, 2019 10:59
AOC2019day8part2
#!/bin/bash
set -eu
set -o pipefail
input=$1
width=$2
height=$3
cd "$(dirname "$0")"
@rhowe
rhowe / 10.sh
Last active December 10, 2019 23:00
AOC2019day10part1
#!/bin/bash
set -u
set -o pipefail
inbounds() {
local x=$1 y=$2
return $((x < 0 || x >= cols || y < 0 || y >= rows ? 1 : 0))
}
@rhowe
rhowe / 10-2.sh
Created December 14, 2019 19:05
AOC2019day10part2
#!/bin/bash
set -u
set -o pipefail
inbounds() {
local x=$1 y=$2
return $((x < 0 || x >= cols || y < 0 || y >= rows ? 1 : 0))
}