~charles/misc

16bbc813758b7d4f3da23f28bba50c19a4f36b0b — Charles Daniels 1 year, 4 days ago bc69bb8
AoC 2021: day 3 part 1
3 files changed, 1020 insertions(+), 0 deletions(-)

A advent2021/day3input.txt
A advent2021/day3p1.awk
A advent2021/day3sample.txt
A advent2021/day3input.txt => advent2021/day3input.txt +1001 -0
@@ 0,0 1,1001 @@
010100010111
100100100110
100110111001
011001011011
010000110111
000011101001
011000011101
101111011111
011001011010
111100001001
111111000110
100010100110
011100100100
011111010000
111010001100
010111001110
100010100100
101000010000
011101110100
100010011000
001111110011
111001100001
010000011001
000011101010
100010101100
111011100010
110000100001
101010110001
111101110101
001010010100
001001111001
100001110010
100100000111
000101010101
001101111011
111100011000
100111110101
010101111000
100110011001
010001111010
010111111001
111000100010
011000011011
100010111111
010110110010
010100000001
100011000100
100000010001
101010001000
100111011001
101011001010
010110110111
111011000100
110010111110
010101000111
000101111101
101101101101
010100010001
000111101111
101101001101
000011110010
000101101011
001111100000
001000100110
111000000100
001000010110
000111010001
111011001010
100011100010
011010101011
001100010001
000001011001
110001101101
010101100001
111000011100
000101000000
001001010101
100000100111
110000001000
111001110100
001111000110
111110000100
100111111000
100101111111
100101011111
111000000011
110000011001
000101000101
110110010011
110111010100
001001101100
101101100001
110011001000
010010100111
000110101011
101010000011
100110001011
000111111011
000100111011
101011111001
011010110110
100101011000
100000010110
000010101000
100100111000
011100011000
000010011001
000001010000
011001110110
111101101010
011110001000
011100110001
011011010101
101011100001
000000111000
110000110011
101111001100
111000101111
100110110110
110000111101
001101110000
100010001110
001001010010
001010000110
000110011001
111111000101
111011011010
101101111010
101001000110
101100100101
001110100000
110001000001
010010011101
011110100010
011000000010
101110100111
000001001010
101101110001
001110101100
011101011001
011010000001
100010011110
000111100010
011000100110
101001010101
000110011010
111100101001
011010000011
010101011101
010011011000
011001000100
010011101111
100110100111
110111010110
011001101101
110001100111
010100111110
111101011010
011010000100
010101101110
101000101100
110110110001
110011110011
111100001100
000011110101
011100000110
011100000111
100101001010
001110010001
011101110111
001101100001
111111010011
101001111110
000000100000
000000100010
101100101000
010011011111
101100100000
000110100100
000010001001
110011000111
101000101101
100101010111
010111001010
000000011011
110110100011
111001100000
000011101101
001011100010
001100110100
010010100010
001001010100
100111010110
001001111000
011011110101
110111101011
000000001000
111110011011
010101011001
001011111111
011011111100
011000001011
101000100000
010011011011
011100111100
011001011110
111001101010
111011111111
100010101010
101100001101
110001000111
100111011010
010000111010
011001101000
111111001001
000111100000
011000010111
110110000111
110100111100
011111000001
000001110100
100110101110
111000111001
010001000000
111001001010
111100111101
101000110100
000101000011
010100101111
010100011010
111110000110
110000010111
010100001100
010000011010
111010000100
000011010010
011001101001
010100111001
011001010111
001001100011
110001100101
101001001001
011101010010
011101011110
000111111110
010111010001
101011011110
001011101101
100110010000
001111100101
011101001110
010111100000
000010111111
101001010000
001101001010
110010111101
001010110110
001001001001
110110110101
000001011011
001110010101
011110000001
101111011011
100000011100
101000010001
000101101100
010111110111
010001101110
011101001000
110100001110
110010110101
101001101000
000101010010
011101001100
100111101100
001011111001
011111101100
100100110001
101001101101
011100001010
000111101101
110010110111
100111010011
000101110110
100111000010
101010000111
101101110101
100000100101
111100010101
111011100111
110011011111
100110100011
111011000101
001010101110
010011000110
110001001111
110100110110
011011011100
111111100100
101010110010
110011101001
000110100001
010011110111
110111001101
100100100100
000111000110
001001010000
001111111110
110000011101
011101011000
110000111001
000100000000
100110111100
111000010101
100010011100
110100111011
010111110110
101111101010
100110111101
110100110101
011111001010
000010010001
011001010010
010111101101
000000110000
111001101110
001011000101
100011011101
101101010100
010000010111
000010101111
001110101010
100000001011
111101011110
110110001000
010100010000
010100110011
000001001110
101011000111
110111101000
001100110111
100110101000
000100111110
101111110000
101001001000
001101001011
111011111101
111011110011
110111111100
110001010100
011110001110
010011100100
101100010000
111010000111
100100011010
100100011011
100001101111
000111100111
001101011010
101110000010
000000000101
110111000110
000010100111
001100101110
000010011101
101100100001
011011000101
100110101100
011000110000
111000100101
011110110101
111011011111
000110010110
001010011110
001110111111
110110011100
111110001001
000001111000
101100101110
011110001001
000101010011
011100100000
100011111010
111011101011
000111100110
101011111010
010100111101
110100110000
000000000011
011000010101
101110110101
011100010101
000111001101
100011010000
010111001100
110000110010
010001001100
000001011100
110111000000
011110011001
101000010110
000100100111
101110000011
001111011001
101010011101
111100110110
111101100000
000000101111
011111011110
000000000111
001000101110
011101101111
011010100011
010101000010
001000101100
010000110100
100010101111
000011010111
011011110000
010101100110
011110001011
101011000001
011100101101
111001100011
100001100101
101011010110
010101000101
001001011111
111010001101
010011001111
001010100110
011101000001
000000111101
111010000101
011000100011
100100011110
010001111011
111100111001
011101111111
001111110000
100100010001
100111100001
001111000011
100010111011
110110000110
110000001010
000000100101
000110111010
100001010100
011011000010
111001001110
100010000000
100101000011
111101010000
001001110110
111010010011
110101101000
101100111001
101010100111
000001101001
000110010001
010001100100
101011100100
111000110000
001100111101
011000111101
110010110110
101101010111
110110100100
101001001011
000101100111
000110010011
011000110011
100011110110
110000101111
100110111000
100000000010
001001011100
100100000110
100001001001
010000011011
110111110100
000110100110
011010000010
110001100110
011000101010
111011011110
100011010110
100001001000
101010101000
011100100110
010000010010
100010010011
100000101011
010110000101
000000101010
000000010111
110110110010
101111010101
000010001000
100000110101
000100111010
111100000100
101000101110
100100001111
000111011101
110100101101
011010010100
001010110011
111110011101
101110111010
001110110110
111100011010
100110000010
111000001110
110010010010
101010100110
011101010011
101100100111
100011101110
111110101010
110011111101
101110001001
001101100101
011010100100
110010001101
010011001010
100100010010
100110011111
110010111001
001111111100
110011111110
111001101000
010101100000
101101000010
100011011110
010000111110
110000111010
011111110110
101010111001
000110111001
100111010000
111001010001
111101001000
111000001101
001100001001
001101111111
011010101001
001100111000
000100101101
010101110000
000100100010
010111010101
110011001111
101001010110
100000001010
110010001110
100011100101
110101011111
101110110011
010010110110
100100001011
111111110110
011100101011
101111110011
110001110001
011011101000
110110000101
101001110000
110111111111
001100000110
001100111111
010101010111
100001001110
110011001010
011010100000
001010101011
000010000101
100101010010
111011110101
111110010001
011000011110
001111111101
011010111100
001011100110
100110101010
101100001000
101011000000
111000010011
001101000111
010001010111
000100000001
000110001101
001111100010
111000100011
111111001010
010011110100
111111000010
001100001100
100010110110
010111101110
100010000111
100101001000
000011011100
110010001111
111000111110
010110001101
100110001100
101001000011
010110010000
010010100101
010110110001
001111001001
101011100111
101010010100
000001101100
100010000110
010111101010
110010100100
110011010000
100110100110
011010110101
000011100111
001001100111
101011100000
010010011000
000010000011
010111111100
001010111101
001111010010
101011110000
110111011100
011100001110
010000000001
101110001100
001011111110
110100100001
011010111101
100110010101
111111100010
100111101010
110010010001
100010111001
001010000000
010011110001
001100010110
001111100100
001011010111
001010110101
010111100101
010100001110
000110010100
000001111101
110101100101
010101100011
011110111000
100001101001
001001001011
111010101101
001111011110
110111110001
001110100100
100011100001
100001111111
100000111001
000110110100
111001110011
010111000110
101100101111
000110001011
110111101101
110101001101
101111101011
111010110101
101101111110
011001001100
010100110101
110100101100
110011101111
010000111101
111101011111
111010111100
011000101001
010000111000
001010001001
100111110111
010111011010
001011010100
011001001101
010011100000
000111010010
000001101110
001101011110
100000010000
010100000010
010010000110
111000101100
101111101100
000101111010
111011011101
011101000011
000111000100
010101111001
100110010001
000001011101
010010101101
100101100111
100101110010
101001000001
110000110001
101110111111
100100000010
011010001110
011011000110
000110001001
010110100101
111001110101
000010011000
010110011011
100110010111
111111010010
101011001101
010011100101
010010110011
101100011100
010111010110
110001101100
000101101000
010011101000
101011100011
000001001100
101111110010
111001111100
000111111010
110100101010
101010110011
000011111010
011100111001
101010001110
010101010001
011110101011
001111001011
010100101001
110001100000
110101000010
011100110011
111111011111
100010000011
101001100111
000000101000
101110110100
110100111010
111101110010
010111111011
111110100100
010001100001
000011010011
000011100011
110010010011
111010011000
101111001111
011000100111
010101101011
001000001101
110110110111
111100010100
100001100001
100010100001
010001011001
101010110000
011110101010
011110111100
100110100010
011111111101
100111001110
101011011111
000011100000
111110101001
000010110010
110000001110
110011111010
001001101111
100010010001
101001010010
111111111010
000000111100
000001000001
100000110100
010000101111
001111111001
001110001010
100111110100
000110111111
010100010100
001000000110
011011110001
100011110011
011101111000
011011000011
110101100011
111101001100
010001001010
010010001101
111110010111
111010011101
100111101011
000110000101
010111011000
111110010011
101001100001
011010100001
100111100011
101010001101
000011101100
010001010001
010000000000
111001100111
110010000101
010011101101
100101000100
000011100101
111101101110
001110101000
010110101111
010011110000
011101011100
011001100100
001101011011
101110011111
100001101010
110111111000
000001111011
101111000100
100100001010
101001110011
010111100010
110111001011
100001000100
001001101000
000001100010
001011001110
001100000000
101110010111
110011101011
001110001101
001000110101
100111101110
000001010101
011001100101
010001000111
011010100101
011110111111
110001000000
000001110000
011101000000
100011000010
110101001011
101100000110
111001001111
110100010110
001001001000
110100011110
101101001000
000001100000
101000000100
000000100110
111101111000
100001101011
111100011101
010001001101
101011010001
001100010010
100101010000
111110010000
101110101001
101001101011
111000011010
001111101101
001001011101
111000010010
111110111100
110000101101
111000000000
001010001010
100001101100
010101110111
001001011001
001110000001
100100101100
011111011010
001001000100
100000111111
111001100110
100101110000
000001001111
111110010100
100101000000
001000000111
010100000101
010101000001
100111000110
110101000100
110110001111
001001000011
111110001101
011000001110
100001111011
101110011001
011011001110
000100100110
100101100010
111110101011
010000101010
000011011110
101110010001
101000011101
101001001010
110101011101
001111110111
110001110000
001011101011
111110000011
100111011011
101011001000
010001000110
100100111010
010111001111
111101000111
011001111110
000110010000
111100111111
000111011111
110000101000
011001101100
111000011011
011110010110
010101100111
011111000101
100111100000
000001001001
010111010100
101010100000
010111001011
110001010111
000110100111
010110010001
010111000001
011010001010
110111010000
000000100001
000110110110
110011111111
011011101100
010011011100
111000011101
000001111111
010100000011
110001111100
100000011001
010100100101
011010010011
000011110110
110100011001
110111100101
000001000100
001110111100
010011010110
100100010111
110111011110
000011111100
110011010011
100110001110
000101001011
110110101001
111010011111
110001010000
100111111100
010000110001
011110000111
110011110001
010110110011
100010001011
110010101011
110111100010
110010001001
100000001100
010110010011
000111111111
011010010111
110101100100
110100000101
100111010001
110110111101
100100001101
100111101000
000111000011
100001010001
101011001100
100100111001
100010001111


A advent2021/day3p1.awk => advent2021/day3p1.awk +7 -0
@@ 0,0 1,7 @@
{for (i=1; i<=length($1); i++) {o[i] += (substr($1, i, 1) == "1"); z[i] += (substr($1, i, 1) == "0")}}
{if (length($1) > m) { m = length($1)}}
END {
	for (i=1; i<=m; i++) {if (o[i] > z[i]) {g += 2**(m-i)}}
	for (i=1; i<=m; i++) {if (o[i] < z[i]) {e += 2**(m-i)}}
	printf("gamma=%d epsilon=%d power=%d\n", g, e, g*e)
}

A advent2021/day3sample.txt => advent2021/day3sample.txt +12 -0
@@ 0,0 1,12 @@
00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010