sstephenson / aoc21

Advent of Code 2021 in the UNIX “little languages”: sh, awk, bc, sed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repository contains solutions to the 2021 Advent of Code written in the “little languages” of UNIX.

The solutions run directly from source and are intended to conform to the POSIX.1-2017 standard.

Languages Used

  • sh - shell, the standard command language interpreter
  • awk - pattern scanning and processing language
  • bc - arbitrary-precision arithmetic language
  • sed - stream editor

Solutions

Day 1 Day 2 Day 3 Day 4 Day 5
Day 6 Day 7 Day 8 Day 9 Day 10
Day 11 Day 12 Day 13 Day 14 Day 15
Day 16 Day 17 Day 18 Day 19 Day 20
Day 21 Day 22 Day 23 Day 24 Day 25

Structure

Each solution consists of a main executable file named solve, and optionally additional source files, in a subdirectory of src/ corresponding to the day and problem. The solve program makes the following assumptions about its environment:

  • The TMPDIR environment variable will be set to the path of a writable temporary directory.
  • The current working directory will be set to the parent directory of the solve program.
  • The program will read the day’s input from stdin.
  • The program will write its solution to stdout and exit with a status of zero.

Advent Harness

The repository includes a built-in harness with scripts to fetch advent problem input, record verified output, and stub, run, and test each day’s solutions.

To evaluate a particular solution, run bin/aoc solve <day> <problem>, where <day> is the advent day number and <problem> is 1 or 2.

To test each solution against the recorded output, run bin/aoc test.


© 2021 Sam Stephenson

About

Advent of Code 2021 in the UNIX “little languages”: sh, awk, bc, sed

License:MIT License


Languages

Language:Awk 53.3%Language:Shell 46.5%Language:sed 0.2%