This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
declare -ai program ram | |
declare -i addrmode1 addrmode2 arg1 arg2 pc=0 rb=0 | |
IFS=, read -r -a program < "$1" | |
shift | |
inputs=("$@") | |
ram=("${program[@]}") | |
ops=(x '+' '*' x x '-eq' '-ne' '<' '==') | |
while : ; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
declare -i width=80 height=50 x=40 y=20 nextx=40 nexty=19 input=1 dir=0 | |
world=$(yes ' ' | tr -d \\n | head -c $((width * height))) | |
declare -ai program ram | |
declare -i addrmode1 addrmode2 arg1 arg2 pc=0 rb=0 | |
IFS=, read -r -a program < "$1" | |
shift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
declare -i width=80 height=50 x=40 y=20 nextx=40 nexty=19 input=1 dir=0 measuredist=0 maxdist=0 | |
declare -a world distances | |
for ((i=0; i < width * height; i++)); do | |
world[i]=' ' | |
distances[i]='.' | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
declare -ai input basepattern | |
read -r inputstr < "${1:?}" | |
for ((i=0; i < ${#inputstr}; i++)); do | |
input+=("${inputstr:$i:1}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
declare -ai ram | |
declare -i addrmode1 addrmode2 arg1 arg2 pc=0 rb=0 | |
IFS=, read -r -a program < input | |
shift | |
ops=(x '+' '*' x x '-eq' '-ne' '<' '==') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sed -e 's#$#/3-2#' |xargs |tr \ +| bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
total=0 | |
while read -r val; do | |
xtra=$((val / 3 - 2)) | |
while [ "$xtra" -gt 0 ]; do | |
total=$((total + xtra)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
IFS=, read -r -a program | |
for noun in $(seq 0 99); do | |
for verb in $(seq 0 99); do | |
program[1]=$noun | |
program[2]=$verb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
seq ${1%-*} ${1#*-} \ | |
| grep -E '(00|11|22|33|44|55|66|77|88|99)' \ | |
| grep -cEv '(10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8])' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set -o pipefail | |
thisisfine=$(seq 0 9 | sed 's/.*/^&&[^&]|[^&]&&[^&]|[^&]&&$/' | xargs | tr \ \|) | |
seq "${1%-*}" "${1#*-}" \ | |
| grep -Ev '10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8]' \ | |
| grep -cE "$thisisfine" |