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 / 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))
}
@rhowe
rhowe / 13.sh
Created December 14, 2019 20:48
AOC2019day13part1
#!/bin/bash -eu
getloc() {
case $1 in
0) echo "$2" ;;
1) echo "Can't get location of immediate value" >&2 && exit 1 ;;
2) echo "$((rb + $2))" ;;
esac
}
@rhowe
rhowe / 14-optim.sh
Created December 16, 2019 08:11
AOC2019day14-optim
#!/bin/bash -eu
declare -A batchsizes recipes
batchsizes[FUEL]=1
batchsizes[ORE]=1
recipefile=$(dirname "$0")/recipes.sh
parse() {
local reaction
@rhowe
rhowe / AOC2019day14
Created December 16, 2019 11:24
14.sh
#!/bin/bash -eu
declare -A stockpile batchsizes recipes
startingore=1000000000000
stockpile[ORE]=$startingore
stockpile[FUEL]=0
batchsizes[ORE]=1
recipefile=$(dirname "$0")/recipes.sh
@rhowe
rhowe / 13.sh
Created December 16, 2019 23:02
AOC2019day13
#!/bin/bash -eu
getloc() {
case $1 in
0) echo "$2" ;;
1) echo "Can't get location of immediate value" >&2 && exit 1 ;;
2) echo "$((rb + $2))" ;;
esac
}
@rhowe
rhowe / 17.sh
Created December 17, 2019 07:38
AOC2019day17part1
#!/bin/bash -eu
getloc() {
case $1 in
0) echo "$2" ;;
1) echo "Can't get location of immediate value" >&2 && exit 1 ;;
2) echo "$((rb + $2))" ;;
esac
}
@rhowe
rhowe / 11.sh
Created December 17, 2019 20:48
AOC2019day11
#!/bin/bash -eu
getloc() {
case $1 in
0) echo "$2" ;;
1) echo "Can't get location of immediate value" >&2 && exit 1 ;;
2) echo "$((rb + $2))" ;;
esac
}
@rhowe
rhowe / 12.sh
Created December 21, 2019 07:59
AOC2019day12part1
#!/bin/bash
set -eu
posx=() posy=() posz=()
velx=() vely=() velz=()
t=0
mapfile -t input < "$1"
@rhowe
rhowe / 12.sh
Created December 24, 2019 16:43
AOCday12part2
#!/bin/bash
set -eu
posx=() posy=() posz=()
velx=() vely=() velz=()
declare -i periodx periody periodz
t=0