From 2204d3a32fe1a035b6ad604bb81b9437dde2230b Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Thu, 9 Dec 2021 20:57:33 +0100 Subject: [PATCH] Add justfiles for 2021 solutions --- 2021/Justfile | 19 +++++++++++++++++++ 2021/day-01/Justfile | 2 ++ 2021/day-02/Justfile | 6 ++++++ 2021/day-03/Justfile | 2 ++ 2021/day-04/Justfile | 2 ++ 2021/day-05/Justfile | 2 ++ 2021/day-06/Justfile | 10 ++++++++++ 2021/day-07/Justfile | 10 ++++++++++ 2021/day-08/Justfile | 6 +++--- 9 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 2021/Justfile create mode 100644 2021/day-01/Justfile create mode 100644 2021/day-02/Justfile create mode 100644 2021/day-03/Justfile create mode 100644 2021/day-04/Justfile create mode 100644 2021/day-05/Justfile create mode 100644 2021/day-06/Justfile create mode 100644 2021/day-07/Justfile diff --git a/2021/Justfile b/2021/Justfile new file mode 100644 index 0000000..50f2036 --- /dev/null +++ b/2021/Justfile @@ -0,0 +1,19 @@ +@_run_day DAY PART INPUT: + just \ + --working-directory "./day-{{DAY}}" \ + --justfile "./day-{{DAY}}/Justfile" \ + part {{PART}} {{INPUT}} + +day DAYS="all" PARTS="one,two" INPUT_FILE="": + #!/usr/bin/env ruby + days = "{{DAYS}}" == "all" ? Dir["day-*"] : "{{DAYS}}".split(",") + input_file = "{{INPUT_FILE}}".then do |f| + (f.include?("/") || f.empty?) ? f : "inputs/#{f}.txt" + end + days.each do |day| + day = day.delete_prefix("day-") + "{{PARTS}}".split(",").each do |part| + part_num = part == "one" ? 1 : 2 + puts "Day #{day}.#{part_num}: " + `just _run_day #{day} #{part} '#{input_file}'` + end + end diff --git a/2021/day-01/Justfile b/2021/day-01/Justfile new file mode 100644 index 0000000..5d62c2c --- /dev/null +++ b/2021/day-01/Justfile @@ -0,0 +1,2 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + ruby part_{{PART}}.rb {{INPUT_FILE}} diff --git a/2021/day-02/Justfile b/2021/day-02/Justfile new file mode 100644 index 0000000..b28e1ea --- /dev/null +++ b/2021/day-02/Justfile @@ -0,0 +1,6 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + gnatmake -q -gnat2020 part_{{PART}} + ./part_{{PART}} {{INPUT_FILE}} + +clean: + rm *.ali *.o part_one part_two diff --git a/2021/day-03/Justfile b/2021/day-03/Justfile new file mode 100644 index 0000000..c9e7619 --- /dev/null +++ b/2021/day-03/Justfile @@ -0,0 +1,2 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + perl part_{{PART}}.pl {{INPUT_FILE}} diff --git a/2021/day-04/Justfile b/2021/day-04/Justfile new file mode 100644 index 0000000..b61a64b --- /dev/null +++ b/2021/day-04/Justfile @@ -0,0 +1,2 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + go run part_{{PART}}.go {{INPUT_FILE}} diff --git a/2021/day-05/Justfile b/2021/day-05/Justfile new file mode 100644 index 0000000..a6b2ad1 --- /dev/null +++ b/2021/day-05/Justfile @@ -0,0 +1,2 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + nim r --hints:off part_{{PART}}.nim {{INPUT_FILE}} diff --git a/2021/day-06/Justfile b/2021/day-06/Justfile new file mode 100644 index 0000000..d1312c4 --- /dev/null +++ b/2021/day-06/Justfile @@ -0,0 +1,10 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + just _inko part_{{PART}}.inko {{INPUT_FILE}} + +_inko FILE INPUT_FILE: + #!/usr/bin/env sh + if type -p inko; then + inko run --include . {{FILE}} {{INPUT_FILE}} + else + echo "inko not found in PATH" + fi diff --git a/2021/day-07/Justfile b/2021/day-07/Justfile new file mode 100644 index 0000000..9da2db4 --- /dev/null +++ b/2021/day-07/Justfile @@ -0,0 +1,10 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + just _swift part_{{PART}}.swift {{INPUT_FILE}} + +_swift FILE INPUT_FILE: + #!/usr/bin/env sh + if test -p swift; then + swift {{FILE}} {{INPUT_FILE}} + else + echo "swift not found in PATH" + fi diff --git a/2021/day-08/Justfile b/2021/day-08/Justfile index 858df41..4656a2b 100644 --- a/2021/day-08/Justfile +++ b/2021/day-08/Justfile @@ -1,6 +1,6 @@ -@part_one INPUT_FILE: - mcs -out:part_one.exe common.cs part_one.cs - mono part_one.exe {{INPUT_FILE}} +@part PART INPUT_FILE="inputs/puzzle.txt": + mcs -out:part_{{PART}}.exe common.cs part_{{PART}}.cs + mono part_{{PART}}.exe {{INPUT_FILE}} clean: rm *.exe