Add justfiles for 2021 solutions

This commit is contained in:
Patrick Auernig 2021-12-09 20:57:33 +01:00
parent 008833b0df
commit 2204d3a32f
9 changed files with 56 additions and 3 deletions

19
2021/Justfile Normal file
View File

@ -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

2
2021/day-01/Justfile Normal file
View File

@ -0,0 +1,2 @@
@part PART INPUT_FILE="inputs/puzzle.txt":
ruby part_{{PART}}.rb {{INPUT_FILE}}

6
2021/day-02/Justfile Normal file
View File

@ -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

2
2021/day-03/Justfile Normal file
View File

@ -0,0 +1,2 @@
@part PART INPUT_FILE="inputs/puzzle.txt":
perl part_{{PART}}.pl {{INPUT_FILE}}

2
2021/day-04/Justfile Normal file
View File

@ -0,0 +1,2 @@
@part PART INPUT_FILE="inputs/puzzle.txt":
go run part_{{PART}}.go {{INPUT_FILE}}

2
2021/day-05/Justfile Normal file
View File

@ -0,0 +1,2 @@
@part PART INPUT_FILE="inputs/puzzle.txt":
nim r --hints:off part_{{PART}}.nim {{INPUT_FILE}}

10
2021/day-06/Justfile Normal file
View File

@ -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

10
2021/day-07/Justfile Normal file
View File

@ -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

View File

@ -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