Skip to content

Commit

Permalink
Simplify scripts around Vim solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
yogan committed Sep 12, 2024
1 parent 9f21470 commit 81af51b
Show file tree
Hide file tree
Showing 85 changed files with 262 additions and 863 deletions.
12 changes: 4 additions & 8 deletions 2015/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@
- [Day 02](https://adventofcode.com/2015/day/2) ⭐⭐ in
[DDP (Die Deutsche Programmiersprache)](day-02-ddp/2015-Tag-02.ddp)
- [Day 03](https://adventofcode.com/2015/day/3) ⭐⭐ in
[Vim](../vim/2015/day-03/aoc-2015-03.vim)
([commented](../vim/2015/day-03/aoc-2015-03.commented.vim))
[Vim](../vim/2015/day-03/aoc.vim)
- [Day 04](https://adventofcode.com/2015/day/4) ⭐⭐ in
[Crystal](day-04-crystal/src/aoc.cr)
([tests](day-04-crystal/spec/aoc_spec.cr))
- [Day 05](https://adventofcode.com/2015/day/5) ⭐⭐ in
[Vim](../vim/2015/day-05/aoc-2015-05.vim)
([commented](../vim/2015/day-05/aoc-2015-05.commented.vim))
[Vim](../vim/2015/day-05/aoc.vim)
- [Day 06](https://adventofcode.com/2015/day/6) ⭐⭐
- [Python](day-06-python/day06.py)
- [Vim](../vim/2015/day-06/aoc-2015-06.vim)
([commented](../vim/2015/day-06/aoc-2015-06.commented.vim))
- [Vim](../vim/2015/day-06/aoc.vim)
- [Day 07](https://adventofcode.com/2015/day/7) ⭐⭐ in
[Gleam](day-07-gleam/src/aoc.gleam)
([tests](day-07-gleam/test/aoc_test.gleam))
- pretty nice recursive solution with a cache dictionary
- [Day 08](https://adventofcode.com/2015/day/8) ⭐⭐
- [JavaScript](day-08-javascript/aoc.mjs)
([tests](day-08-javascript/aoc.test.mjs))
- [Vim](../vim/2015/day-08/aoc-2015-08.vim)
([commented](../vim/2015/day-08/aoc-2015-08.commented.vim))
- [Vim](../vim/2015/day-08/aoc.vim)
- [fish](day-08-fish/aoc.fish) ([tests](day-08-fish/test.fish))
- easy thanks to `eval()` (both JS and Vim) and
`string escape` / `string unescape` (fish)
Expand Down
21 changes: 7 additions & 14 deletions 2016/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# [Advent of Code 2016](https://adventofcode.com/2016)

- [Day 01](https://adventofcode.com/2016/day/1) ⭐⭐ in
[Vim](../vim/2016/day-01/aoc-2016-01.vim)
([commented](../vim/2016/day-01/aoc-2016-01.commented.vim))
[Vim](../vim/2016/day-01/aoc.vim)
- [Day 02](https://adventofcode.com/2016/day/2) ⭐⭐ in
[Vim](../vim/2016/day-02/aoc-2016-02.vim)
([commented](../vim/2016/day-02/aoc-2016-02.commented.vim))
[Vim](../vim/2016/day-02/aoc.vim)
- [Day 03](https://adventofcode.com/2016/day/3) ⭐⭐ in
[Vim](../vim/2016/day-03/aoc-2016-03.vim)
([commented](../vim/2016/day-03/aoc-2016-03.commented.vim))
[Vim](../vim/2016/day-03/aoc.vim)
- [Day 04](https://adventofcode.com/2016/day/4) ⭐⭐ in
[Vim](../vim/2016/day-04/aoc-2016-04.vim)
([commented](../vim/2016/day-04/aoc-2016-04.commented.vim))
[Vim](../vim/2016/day-04/aoc.vim)
- [Day 05](https://adventofcode.com/2016/day/5) ⭐⭐ in
- [Gleam](./day-05-gleam/src/aoc_2016_day_05.gleam)
([tests](./day-05-gleam/test/aoc_2016_day_05_test.gleam))
Expand All @@ -20,15 +16,13 @@
but not much. Gleam runs ~26 sec, while Rust runs ~19 sec. It probably comes
down to how performant the MD5 implementations are.
- [Day 06](https://adventofcode.com/2016/day/6) ⭐⭐ in
[Vim](../vim/2016/day-06/aoc-2016-06.vim)
([commented](../vim/2016/day-06/aoc-2016-06.commented.vim))
[Vim](../vim/2016/day-06/aoc.vim)
- [Day 07](https://adventofcode.com/2016/day/7) ⭐⭐ in Haskell
([Main.hs](./day-07-haskell/app/Main.hs),
[Lib.hs](./day-07-haskell/src/Lib.hs),
[Spec.hs](./day-07-haskell/test/Spec.hs))
- [Day 08](https://adventofcode.com/2016/day/8) ⭐⭐ in
[Vim](../vim/2016/day-08/aoc-2016-08.vim)
([commented](../vim/2016/day-08/aoc-2016-08.commented.vim)) -
[Vim](../vim/2016/day-08/aoc.vim)
[animated solution](../vim/2016/day-08/README.md)
- [Day 09](https://adventofcode.com/2016/day/9) ⭐⭐ in Elixir
([aoc.ex](./day-09-elixir/lib/aoc.ex),
Expand Down Expand Up @@ -63,8 +57,7 @@
([aoc.py](./day-14-python/aoc.py))
- using [`@functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache)
- [Day 15](https://adventofcode.com/2016/day/15) ⭐⭐ in
[Vim](../vim/2016/day-15/aoc-2016-15.vim)
([commented](../vim/2016/day-15/aoc-2016-15.commented.vim))
[Vim](../vim/2016/day-15/aoc.vim)
- the puzzle is pretty much exactly the [Chinese Remainder
Theorem](https://en.wikipedia.org/wiki/Chinese_remainder_theorem)
- initially solved by hand, see [Day 15 README](../vim/2016/day-15/README.md)
Expand Down
3 changes: 1 addition & 2 deletions 2017/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
[`main.jl`](day-01-julia/src/main.jl),
[`runtests.jl`](day-01-julia/test/runtests.jl))
- [Day 02](https://adventofcode.com/2017/day/2) ⭐⭐ in
[Vim](../vim/2017/day-02/aoc-2017-02.vim)
([commented](../vim/2017/day-02/aoc-2017-02.commented.vim))
[Vim](../vim/2017/day-02/aoc.vim)
28 changes: 15 additions & 13 deletions 2022/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# [Advent of Code 2022](https://adventofcode.com/2022) (46/50 ✨)

**Languages: 14** *(fish, JavaScript, TypeScript, Perl, Ruby, C, Java, Fortran, Nim,
Lua, C#, Python, Haskell, Vim)*
**Languages: 14** *(fish, JavaScript, TypeScript, Perl, Ruby, C, Java, Fortran,
Nim, Lua, C#, Python, Haskell, Vim)*
**Ideas for 2023:** see [languages.md](languages.md)

- [Day 01](https://adventofcode.com/2022/day/1) ⭐⭐
- [fish](day-01-fish/day01.fish) with [tests](day-01-fish/test.fish)
- [Vim](../vim/2022/day-01/aoc-2022-01.vim)
([commented](../vim/2022/day-01/aoc-2022-01.commented.vim))
- [Vim](../vim/2022/day-01/aoc.vim)
- [Day 02](https://adventofcode.com/2022/day/2) ⭐⭐
- [JavaScript (Node/esm)](day-02-javascript/day02.mjs),
[tests](day-02-javascript/day02.test.mjs) for Node 19's experimental built-in test runner
- [Vim](../vim/2022/day-02/aoc-2022-02.vim)
([commented](../vim/2022/day-02/aoc-2022-02.commented.vim))
[tests](day-02-javascript/day02.test.mjs) for Node 19's experimental
built-in test runner
- [Vim](../vim/2022/day-02/aoc.vim)
- [Day 03](https://adventofcode.com/2022/day/3) ⭐⭐
- [TypeScript (Bun)](day-03-typescript/day03.ts),
[tests](day-03-typescript/day03.test.ts) require Bun Canary, see [README](day-03-typescript/README.md)
- [Vim](../vim/2022/day-03/aoc-2022-03.vim)
([commented](../vim/2022/day-03/aoc-2022-03.commented.vim))
[tests](day-03-typescript/day03.test.ts) require Bun Canary, see
[README](day-03-typescript/README.md)
- [Vim](../vim/2022/day-03/aoc.vim)
- [Day 04](https://adventofcode.com/2022/day/4) ⭐⭐ in
[Perl](day-04-perl/day04.pl) with [Test2](https://metacpan.org/pod/Test2)
- [Day 05](https://adventofcode.com/2022/day/5) ⭐⭐ in
Expand All @@ -42,7 +41,8 @@ Lua, C#, Python, Haskell, Vim)*
- [Day 12](https://adventofcode.com/2022/day/12) ⭐⭐ in
[Python](day-12-python/day12.py) no tests, but quickly done
- [Day 13](https://adventofcode.com/2022/day/13) ⭐⭐ in
[Python](day-13-python/day13.py) input data is recursive and almost valid Python syntax, so Python /w `eval`
[Python](day-13-python/day13.py) input data is recursive and almost valid
Python syntax, so Python /w `eval`
- [Day 14](https://adventofcode.com/2022/day/14) ⭐⭐ in
[Python](day-14-python/day14.py) with [visualization](day-14-python/README.md)
- [Day 15](https://adventofcode.com/2022/day/15) ⭐⭐ in
Expand All @@ -60,11 +60,13 @@ Lua, C#, Python, Haskell, Vim)*
- [Day 20](https://adventofcode.com/2022/day/20) ⭐⭐ in
[Python](day-20-python/day20.py) modulo goes brrrr
- [Day 21](https://adventofcode.com/2022/day/21) ⭐⭐ in
[Python](day-21-python/day21.py) expression trees and brute force binary search (with a bit of luck)
[Python](day-21-python/day21.py) expression trees and brute force binary search
(with a bit of luck)
- [Day 22](https://adventofcode.com/2022/day/22) ⭐✖️ in
[Python](day-22-python/day22.py) part 1 only
- [Day 23](https://adventofcode.com/2022/day/23) ⭐⭐ in
[Python](day-23-python/day23.py) actually quite nice and clean code (pattern matching, list/set comprehensions)
[Python](day-23-python/day23.py) actually quite nice and clean code
(pattern matching, list/set comprehensions)
- [Day 24](https://adventofcode.com/2022/day/24) ⭐⭐ in
[Python](day-24-python/day24.py) BFS (caching blizzard cycles == *huge* performance boost)
- [Day 25](https://adventofcode.com/2022/day/25) ⭐✖️ in
Expand Down
12 changes: 4 additions & 8 deletions 2023/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@

## [Day 01: Trebuchet?!](https://adventofcode.com/2023/day/1) 🚀
- ⭐⭐ [fish](day-01-fish/day01.fish) with [tests](day-01-fish/test.fish) 🐟
- ⭐⭐ [Vim](../vim/2023/day-01/aoc-2023-01.vim)
[(commented)](../vim/2023/day-01/aoc-2023-01.commented.vim)
- ⭐⭐ [Vim](../vim/2023/day-01/aoc.vim)

## [Day 02: Cube Conundrum](https://adventofcode.com/2023/day/2) 🧊
- ⭐⭐ [Clojure](day-02-clojure/src/advent_of_code_template/core.clj)
with [tests](day-02-clojure/test/advent_of_code_template/core_test.clj) 📃
- ⭐⭐ [Vim](../vim/2023/day-02/aoc-2023-02.vim)
[(commented)](../vim/2023/day-02/aoc-2023-02.commented.vim)
- ⭐⭐ [Vim](../vim/2023/day-02/aoc.vim)

## [Day 03: Gear Ratios](https://adventofcode.com/2023/day/3) ⚙️
- ⭐⭐ [Python](day-03-python/day03.py) 🐍
- ⭐⭐ [Vim](../vim/2023/day-03/aoc-2023-03.vim)
[(commented)](../vim/2023/day-03/aoc-2023-03.commented.vim)
- ⭐⭐ [Vim](../vim/2023/day-03/aoc.vim)

## [Day 04: Scratchcards](https://adventofcode.com/2023/day/4)
- ⭐⭐ [DDP - Die Deutsche Programmiersprache](day-04-ddp/Tag4.ddp) 🥨
- ⭐⭐ [Vim](../vim/2023/day-04/aoc-2023-04.vim)
[(commented)](../vim/2023/day-04/aoc-2023-04.commented.vim)
- ⭐⭐ [Vim](../vim/2023/day-04/aoc.vim)

## [Day 05: If You Give A Seed A Fertilizer](https://adventofcode.com/2023/day/5) 🌱
- ⭐⭐ [Python](day-05-python/day05.py)
Expand Down
5 changes: 0 additions & 5 deletions scripts/run-vim.sh

This file was deleted.

1 change: 1 addition & 0 deletions vim/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out
*.out
*.stripped.vim
*.sw?
44 changes: 0 additions & 44 deletions vim/2015/day-03/aoc-2015-03.vim

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions vim/2015/day-03/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
sed -e '/^\("\|:\?$\)/d' <aoc.vim >aoc.stripped.vim
vim --clean -s "aoc.stripped.vim" 1>/dev/null 2> \
>(grep -v "Vim: Warning: Output is not to a terminal" >&2)
cat out
rm -f aoc.stripped.vim out
11 changes: 5 additions & 6 deletions vim/2015/day-03/test-ci.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/sh
../../../scripts/run-vim.sh > /dev/null 2>&1

result1=$(head -1 out)
result2=$(tail -1 out)
expected1="2572"
expected2="2631"
output=$(./run.sh)

expected1=2572
result1=$(echo "$output" | head -1)
if [ "$result1" != "$expected1" ]; then
echo "Part 1 failed"
echo "Expected: »$expected1«"
echo "Received: »$result1«"
exit 1
fi

expected2=2631
result2=$(echo "$output" | tail -1)
if [ "$result2" != "$expected2" ]; then
echo "Part 2 failed"
echo "Expected: »$expected2«"
Expand Down
14 changes: 0 additions & 14 deletions vim/2015/day-05/aoc-2015-05.vim

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions vim/2015/day-05/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
sed -e '/^\("\|:\?$\)/d' <aoc.vim >aoc.stripped.vim
vim --clean -s "aoc.stripped.vim" 1>/dev/null 2> \
>(grep -v "Vim: Warning: Output is not to a terminal" >&2)
cat out
rm -f aoc.stripped.vim out
12 changes: 5 additions & 7 deletions vim/2015/day-05/test-ci.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#!/bin/sh
GIT_ROOT=$(git rev-parse --show-toplevel)
"${GIT_ROOT}"/scripts/run-vim.sh

result1=$(head -1 out)
result2=$(tail -1 out)
expected1="255"
expected2="55"
output=$(./run.sh)

expected1=255
result1=$(echo "$output" | head -1)
if [ "$result1" != "$expected1" ]; then
echo "Part 1 failed"
echo "Expected: »$expected1«"
echo "Received: »$result1«"
exit 1
fi

expected2=55
result2=$(echo "$output" | tail -1)
if [ "$result2" != "$expected2" ]; then
echo "Part 2 failed"
echo "Expected: »$expected2«"
Expand Down
55 changes: 0 additions & 55 deletions vim/2015/day-06/aoc-2015-06.vim

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions vim/2015/day-06/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
sed -e '/^\("\|:\?$\)/d' <aoc.vim >aoc.stripped.vim
vim --clean -s "aoc.stripped.vim" 1>/dev/null 2> \
>(grep -v "Vim: Warning: Output is not to a terminal" >&2)
cat out
rm -f aoc.stripped.vim out
11 changes: 5 additions & 6 deletions vim/2015/day-06/test-ci.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/sh
../../../scripts/run-vim.sh > /dev/null 2>&1

result1=$(head -1 out)
result2=$(tail -1 out)
expected1="569999"
expected2="17836115"
output=$(./run.sh)

expected1=569999
result1=$(echo "$output" | head -1)
if [ "$result1" != "$expected1" ]; then
echo "Part 1 failed"
echo "Expected: »$expected1«"
echo "Received: »$result1«"
exit 1
fi

expected2=17836115
result2=$(echo "$output" | tail -1)
if [ "$result2" != "$expected2" ]; then
echo "Part 2 failed"
echo "Expected: »$expected2«"
Expand Down
Loading

0 comments on commit 81af51b

Please sign in to comment.