-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
results.txt | ||
.*.sw? | ||
*.so |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
AWK solutions for Advent of Code 2023 | ||
===================================== | ||
I decided to implement the Advent of Code challenges this year in AWK. This | ||
daily programming challenge can be found at http://www.adventofcode.com. | ||
|
||
Here are my solutions. There is a folder for each day, each containing: | ||
|
||
| file | description | | ||
| ------------ | ------------------------------------------- | | ||
| Makefile | Makefile that runs a regression by default | | ||
| expected.txt | Expected results of regression test | | ||
| sample.txt | sample input from the challenge description | | ||
| input.txt | test input from the challenge description | | ||
| one.awk | first solution | | ||
| two.awk | second solution | | ||
| * | additional files as needed | | ||
|
||
Jerry Williams | ||
gsw@wfam.info |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
cd $(dirname $0) | ||
for d in day* | ||
do | ||
echo + $d | ||
make -C $d clean | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: test clean update | ||
|
||
test : expected.txt results.txt | ||
diff -s expected.txt results.txt | ||
|
||
PROGRAMS = one.awk two.awk | ||
INPUTS = sample.txt input.txt | ||
|
||
results.txt : $(PROGRAMS) $(INPUTS) | ||
./one.awk sample.txt > $@ | ||
./one.awk input.txt >> $@ | ||
./two.awk sample.txt >> $@ | ||
./two.awk input.txt >> $@ | ||
cat $@ | ||
|
||
clean: | ||
$(RM) results.txt | ||
|
||
update: results.txt | ||
cp $< expected.txt |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0 | ||
2 | ||
0 | ||
2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env gawk -f | ||
BEGIN { | ||
} | ||
{ | ||
if (_error) { | ||
print "DATA ERROR" | ||
exit _exit=1 | ||
} | ||
} | ||
END { | ||
if (_exit) { | ||
exit _exit | ||
} | ||
print NR | ||
} |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env gawk -f | ||
BEGIN { | ||
} | ||
{ | ||
if (_error) { | ||
print "DATA ERROR" | ||
exit _exit=1 | ||
} | ||
} | ||
END { | ||
if (_exit) { | ||
exit _exit | ||
} | ||
print NR | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
cd $(dirname $0) | ||
export PREVENT_LONG_RUN=1 | ||
for d in day* | ||
do | ||
echo + $d | ||
make -C $d | ||
done |