Skip to content

Instantly share code, notes, and snippets.

@mcsf
Last active July 21, 2021 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsf/7ba1266dba0cda0f1fd11f5139112d6e to your computer and use it in GitHub Desktop.
Save mcsf/7ba1266dba0cda0f1fd11f5139112d6e to your computer and use it in GitHub Desktop.
Advent of Code 2019, day 08
#!/usr/bin/env awk -f
{
delete counts
for (i = 1; i <= NF; i++) counts[$i]++
if (! min || counts[0] < min) {
min = counts[0]
result = counts[1] * counts[2]
}
}
END { print result }
#!/usr/bin/env perl -p
s/.*?(0|1).*/\1/
#!/bin/bash
W=25
H=6
LAYERS=$(fold -w $((W * H)) | sed 's/\(.\)/\1 /g')
# Part 1
<<< "$LAYERS" ./checksum
# Part 2
<<< "$LAYERS" rs -T | ./find-first-meaningful-pixel | rs $H $W | sed 's/0/ /g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment