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
function day8 \ | |
--description "https://adventofcode.com/2021/day/8 - usage: day8 part1 datafile.dat" \ | |
--argument-names part datafile | |
test -f "$datafile"; or echo >&2 "file expected" && return 1 | |
set part (string match --regex '.$' $part) | |
day8part$part $datafile | |
end |
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
function aoc2021_day7 \ | |
--description "https://adventofcode.com/2021/day/7 - usage: aoc2021_day7 part1 datafile.dat" \ | |
--argument-names part datafile | |
test -f "$datafile"; or echo >&2 "file expected" && return 1 | |
set part (string match --regex '.$' $part) | |
set --local crab_alignment (string split ',' <$datafile) | |
set --local possible_positions (echo $crab_alignment | tr ' ' '\n' | sort -n | uniq) | |
set --local min_pos (echo $possible_positions | tr ' ' '\n' | sort -n | head -n 1) | |
set --local max_pos (echo $possible_positions | tr ' ' '\n' | sort -n | tail -n 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
function day6 \ | |
--description "https://adventofcode.com/2021/day/6 - usage: day6 part1 datafile.dat" \ | |
--argument-names part datafile | |
test -f "$datafile"; or echo >&2 "file expected" && return 1 | |
set part (string match --regex '.$' $part) | |
set --local total_days (test $part -eq 1 && echo 80 || echo 256) | |
set --local lantern_fish_timers (string split ',' <$datafile) | |
set --local new_fish_each_day (string split '' (string repeat -n $total_days 0)) |
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
function day5 \ | |
--description "https://adventofcode.com/2021/day/5#part2 - usage: day5 part1 datafile.dat" \ | |
--argument-names part datafile | |
test -f "$datafile" || or set datafile (realpath (status dirname)/../data/day5.dat) | |
set part (string match --regex '.$' $part) | |
#day5-sanitychecks $datafile | |
# make a temp file of all points | |
set --local data (cat $datafile) |
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
function day4 \ | |
--description "https://adventofcode.com/2021/day/4 - usage: day4 part1 datafile.dat" \ | |
--argument-names part datafile | |
set part (string match --regex '.$' $argv[1]) | |
if test "$part" -ne 1 && test "$part" -ne 2 | |
echo "Expecting part number 1 or 2 '$part'" >&2 && return 1 | |
end | |
test -n "$datafile"; \ | |
or set datafile (realpath (status dirname)/../data/day4.dat) |
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
function day3 \ | |
--description "https://adventofcode.com/2021/day/3 - usage: day3 part1 datafile.dat" \ | |
--argument-names part datafile | |
set part (string match --regex '.$' $argv[1]) | |
if test "$part" -ne 1 && test "$part" -ne 2 | |
echo "Expecting part number 1 or 2 '$part'" >&2 && return 1 | |
end | |
test -n "$datafile"; \ | |
or set datafile (realpath (status dirname)/../data/day3.dat) |
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
function day2 \ | |
--description "https://adventofcode.com/2021/day/2: `usage - day2 1 data.txt`" \ | |
--argument-names part datafile | |
if test "$part" -ne 1 && test "$part" -ne 2 | |
echo "Expecting part number 1 or 2 '$part'" >&2 && return 1 | |
end | |
set --global horizontal_position 0 | |
set --global depth_position 0 |
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
function day1part1 \ | |
--description "https://adventofcode.com/2021/day/1" | |
set --local inputfile (realpath (status dirname)/day1_input.txt) | |
set --local depth_data (cat $inputfile) | |
set --local depth_increased_counter 0 | |
set --local depth_decreased_counter 0 | |
set --local depth_same_counter 0 | |
set --local previous_measurement $depth_data[1] | |
for index in (seq 2 (count $depth_data)) |
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
// ==UserScript== | |
// @name stackoverflow tampering | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description StackOverflow - hide #hot-network-questions and deleted stuff. | |
// @author mattmc3 | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js | |
// @match https://*.stackoverflow.com/* | |
// @match https://*.stackexchange.com/* |
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
#!/usr/bin/env -S awk -f | |
# https://testanything.org | |
BEGIN { | |
CYAN="\033[0;36m" | |
GREEN="\033[0;32m" | |
RED="\033[0;31m" | |
BRIGHTGREEN="\033[1;92m" | |
BRIGHTRED="\033[1;91m" | |
NORMAL="\033[0;0m" |