From 09cbfeeca74e6b7ca9a9b5d49646c538b8a3f4ba Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Mon, 7 Dec 2015 15:16:10 +0000 Subject: Rearranged into folders, added makefile for convenience. --- Makefile | 17 + day1.c | 21 -- day1.input | 1 - day1.readme | 34 -- day1/Makefile | 1 + day1/day1.c | 21 ++ day1/day1.input | 1 + day1/day1.readme | 34 ++ day2.c | 56 --- day2.input | 1000 ------------------------------------------------------ day2.readme | 25 -- day2/Makefile | 1 + day2/day2.c | 56 +++ day2/day2.input | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ day2/day2.readme | 25 ++ day3.c | 87 ----- day3.input | 1 - day3.readme | 27 -- day3/Makefile | 1 + day3/day3.c | 87 +++++ day3/day3.input | 1 + day3/day3.readme | 27 ++ day4.c | 53 --- day4.readme | 14 - day4/Makefile | 1 + day4/day4.c | 56 +++ day4/day4.input | 2 + day4/day4.readme | 14 + day4/override.mk | 1 + day5.c | 52 --- day5.input | 1000 ------------------------------------------------------ day5.readme | 37 -- day5/Makefile | 1 + day5/day5.c | 52 +++ day5/day5.input | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ day5/day5.readme | 37 ++ day6.c | 65 ---- day6.input | 300 ---------------- day6.readme | 38 --- day6/Makefile | 1 + day6/day6.c | 65 ++++ day6/day6.input | 300 ++++++++++++++++ day6/day6.readme | 38 +++ readme.textile | 7 +- 44 files changed, 2846 insertions(+), 2812 deletions(-) create mode 100644 Makefile delete mode 100644 day1.c delete mode 100644 day1.input delete mode 100644 day1.readme create mode 120000 day1/Makefile create mode 100644 day1/day1.c create mode 100644 day1/day1.input create mode 100644 day1/day1.readme delete mode 100644 day2.c delete mode 100644 day2.input delete mode 100644 day2.readme create mode 120000 day2/Makefile create mode 100644 day2/day2.c create mode 100644 day2/day2.input create mode 100644 day2/day2.readme delete mode 100644 day3.c delete mode 100644 day3.input delete mode 100644 day3.readme create mode 120000 day3/Makefile create mode 100644 day3/day3.c create mode 100644 day3/day3.input create mode 100644 day3/day3.readme delete mode 100644 day4.c delete mode 100644 day4.readme create mode 120000 day4/Makefile create mode 100644 day4/day4.c create mode 100644 day4/day4.input create mode 100644 day4/day4.readme create mode 100644 day4/override.mk delete mode 100644 day5.c delete mode 100644 day5.input delete mode 100644 day5.readme create mode 120000 day5/Makefile create mode 100644 day5/day5.c create mode 100644 day5/day5.input create mode 100644 day5/day5.readme delete mode 100644 day6.c delete mode 100644 day6.input delete mode 100644 day6.readme create mode 120000 day6/Makefile create mode 100644 day6/day6.c create mode 100644 day6/day6.input create mode 100644 day6/day6.readme diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6013a09 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +DAY=$(notdir ${PWD}) +CFLAGS= +DAYFLAGS= +INPUT=${DAY}.input + +-include override.mk + +${DAY}: ${DAY}.c + @gcc ${CFLAGS} -o $@ $< ${DAYFLAGS} + +run: ${DAY} ${INPUT} + @./${DAY} < ${INPUT} + +clean: + @rm -f ${DAY} + +.PHONY: run clean diff --git a/day1.c b/day1.c deleted file mode 100644 index dbd188d..0000000 --- a/day1.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int main() { - int ch, floor = 0, pos = 0, first_basement = 1; - while ((ch = getchar()) != EOF) { - pos += 1; - switch(ch) { - case '(': - floor += 1; - break; - case ')': - floor -= 1; - } - if (floor == -1 && first_basement) { - printf("In the basement at position: %d\n", pos); - first_basement = 0; - } - } - printf("Final floor: %d\n", floor); - return 0; -} diff --git a/day1.input b/day1.input deleted file mode 100644 index becde71..0000000 --- a/day1.input +++ /dev/null @@ -1 +0,0 @@ -((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()()(()(((()(((((())()))()((()(()))()((()((((())((((())(()(((())()()(()()()()()(())((((())((())(()()))()((((())))((((()())()((((())((()())((())(())(((((()((((()(((()((((())(()(((()()))()))((((((()((())()())))(((()(()))(()()(()(((()(()))((()()()())((()()()(((())())()())())())((()))(()(()))(((((()(()(())((()(())(())()((((()())()))((((())(())((())())((((()(((())(())((()()((((()((((((()(())()()(()(()()((((()))(())()())()))(())))(())))())()()(())(()))()((()(()(())()()))(()())))))(()))(()()))(())(((((()(()(()()((())()())))))((())())((())(()(())((()))(())(((()((((((((()()()(()))()()(((()))()((()()(())(())())()(()(())))(((((()(())(())(()))))())()))(()))()(()(((((((()((((())))())())())())()((((((((((((((()()((((((()()()())())()())())())(())(())))())((()())((()(()))))))()))))))))))))))))())((())((())()()))))))(((()((()(()()))((())(()()))()()())))(())))))))(()(((())))())()())))()()(())()))()(()))())((()()))))(()))))()))(()()(())))))))()(((()))))()(()))(())())))))()))((()))((()))())(())))))))))((((())()))()))()))())(())()()(())))())))(()())()))((()()(())))(())((((((()(())((()(((()(()()(())))()))))))()))()(()((()))()(()))(()(((())((((())())(())(()))))))))())))))))())())))))())))))()()(((())()(()))))))))())))))(())()()()))()))()))(()(())()()())())))))))())()(()(()))))()()()))))())(()))))()()))))()())))))(((())()()))(()))))))))))()()))))()()()))))(()())())()()())()(()))))()(()))(())))))))(((((())(())())()()))()()))(())))))()(()))))(())(()()))()())()))()))()))()))))())()()))())())))(()))(()))))))())()(((())()))))))))()))()())))())))())))()))))))))))()()))(()()))))))(())()(()))))())(()))))(()))))(()())))))())())()()))))())()))))))))(()))))()))))))()(()())))))))()))())))())))())))())))))))())(()()))))))(()())())))()())()))))))))))))))())))()(())))()))())()()(())(()()))(())))())()())(()(()(()))))())))))))))))())(()))()))()))))(())()())()())))))))))))()()))))))))))))())())))))(()())))))))))))())(())))()))))))))())())(()))()))(())))()))()()(())()))))))()((((())()))())())))))()))()))))((()())()))))())))(())))))))))))))))))()))))()()())()))()()))))())()))((()())))())))(()))(()())))))))()))()))))(())))))))(())))))())()()(()))())()))()()))))())()()))))())()))())))))))(()))))()())()))))))))(()))())))(()))()))))(())()))())())(())())())))))))((((())))))()))()))()())()(())))()))()))()())(()())()()(()())()))))())())))))(()))()))))())(()()(())))))(())()()((())())))))(())(())))))))())))))))))()(())))))))()())())())()(()))))))))(()))))))))())()()))()(()))))))()))))))())))))))(())))()()(())()())))))(((())))()((())()))())))(()()))())(())())))()(((()())))))()(()()())))()()(()()(()()))())()(()()()))())()()))()())(()))))())))))())))(())()()))))(()))))(())(()))(())))))()()))()))))())()))()()(())())))((()))())()))))))()()))))((()(()))))()()))))))())))))())(()((()())))))))))))()())())))()))(()))))))(()))(())()())))(()))))))))())()()()()))))(()())))))))((())))()))(()))(())(())()())()))))))))(())))())))(()))()()))(()()))(()))())))()(())))())((()((()(())))((())))()))))((((())())()())))(())))()))))))())(()()((())))())()(()())))))(()())()))())))))))((())())))))))(()(()))())()()(()()(((()(((()())))))()))))))()(())(()()((()()(())()()))())()())()))()())())())))))))(((())))))))()()))))))(((())()))(()()))(()()))))(()(()()((((())()())((()()))))(()(())))))()((()()()())()()((()((()()))(()))(((()()()))(((())))()(((())()))))))((()(())())))(()())(((((()(()))(()((()))(()())()))))(()(()))()(()))(())(((())(()()))))()()))(((()))))(()()()()))())))((()()()(())()))()))))()()))()))))))((((((()()()))))())((()()(((()))))(()(())(()()())())())))()(((()()))(())((())))(()))(()()()())((())())())(()))))()))()((()(())()(()()(())(()))(())()))(())(()))))(())(())())(()()(()((()()((())))((()))()((())))(((()()()()((((()))(()()))()()()(((())((())())(()()(()()()))()((())(())()))())(((()()(())))()((()()())()())(()(())())(((())(())())((())(())()(((()()))(())))((())(()())())(())((()()()((((((())))((()(((((())()))()))(())(()()))()))(())()()))(())((()()())()()(()))())()((())))()((()()())((((()())((())())())((()((()))()))((())((()()(()((()()(((())(()()))))((()((())()(((())(()((())())((())(()((((((())())()(()())()(())(((())((((((()(())(()((()()()((()()(()()()())))()()(((((()()))()((((((()))()(()(()(()(((()())((()))())()((()))(())))()))()()))())()()))())((((())(()(()))(((((((())(((()(((((()(((()()((((())(((())())))(()()()(()(()))()))((((((()))((()(((()(())((()((((()((((((())(((((())))(((()(()))))(((()(((())()((())(()((()))(((()()(((())((((()(()(((((()))(((()(((((((()(()()()(()(()(()()())(())(((((()(())())()())(()(()(()))()(()()()())(()()(()((()))()((())())()(()))((())(()))()(()))()(((()(()(()((((((()()()()())()(((((()()(((()()()((()(((((()))((((((((()()()(((((()))))))(()()()(())(()))(()()))))(())()))(((((()(((((()()(()(()())(((()))((((()((()(()(()((()(()((())))()(((()((()))((()))(((((((((()((()((()(())))()((((()((()()))((())(((()(((((()()(()(()()((()(()()()(((((((())())()())))))((((()()(()))()))(()((())()(()(((((((((()()(((()(()())(()((()())((())())((((()(((()(((()((((()((()((((()(()((((((())((((((((((((()()(()()((((((((((((((()((()()))()((((((((((((())((((()(()())((()(()(()))()(((((()()(((()()))()())(())((()(((((()((())(((((()((()(((((()))()()((((())()((((())(((((((((()(())(()(())))())(()((())(((())(())(())())(()(()(())()()((()((())()(((()(((((()(())))()(((()((())))((()()()(((()(((()((()(()(())(()((()())(()(()(((()(((((((((())(()((((()()))(()((((()()()()(((()((((((((()(()()((((((()(()()(()((()((((((((((()()(((((((()())(())))(((()()))(((((()((()()())(()()((((())((()((((()))))(())((()(()()(((()(()(((()((((()(((((()))())())(()((())()))(((()())((())((())((((()((()((((((())(()((((()()))((((((())()(()))((()(((())((((((((((()()(((((()(((((()((()()()((((())))(()))()((()(())()()((()((((((((((()((())(())(((((()(()(()()))((((()((((()()((()(((()(((((((((()(()((()((()))((((((()(((())()()((()(((((((()())))()()(()((()((()()(((()(()()()()((((()((())((((()(((((((((()(((()()(((()(()(((()(((()((())()(()((()(()(()(()))()(((()))(()((((()((())((((())((((((())(()))(()((((())((()(()((((((((()()((((((()(()(()()()(())((()((()()(((()(((((((()()((()(((((((()))(((((()(((()(()()()(()(((()((()()((())(()(((((((((()(()((()((((((()()((())()))(((((()((())()())()(((((((((((()))((((()()()()())(()()(()(()()))()))(()))(()(((()()))())(()(()))()()((())(()())()())()(()))()))(()()(()((((((())((()(((((((((((()(())()((()(()((()((()(()((()((((((((((()()())((())()(())))((())()())()(((((()(()())((((()((()(())(()))(((())()((()))(((((())(()))()()(()))(((())((((()((((()(())))(((((((()))))())()())(())((())()(()()((()(()))()(()()(()()((()())((())((()()))((((()))()()))(()()(())()()(((((()(())((()((((()))()))(()())())(((()()(()()))(())))))(()))((())(((((()((((()))()((((()))()((())(((())))(((()())))((()(()()(( diff --git a/day1.readme b/day1.readme deleted file mode 100644 index 0da69d3..0000000 --- a/day1.readme +++ /dev/null @@ -1,34 +0,0 @@ ---- Day 1: Not Quite Lisp --- - -Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December 25th. - -Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! - -Here's an easy puzzle to warm you up. - -Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time. - -An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor. - -The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors. - -For example: - - - (()) and ()() both result in floor 0. - - ((( and (()(()( both result in floor 3. - - ))((((( also results in floor 3. - - ()) and ))( both result in floor -1 (the first basement level). - - ))) and )())()) both result in floor -3. - -To what floor do the instructions take Santa? - ---- Part Two --- - -Now, given the same instructions, find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on. - -For example: - - - ) causes him to enter the basement at character position 1. - - ()()) causes him to enter the basement at character position 5. - -What is the position of the character that causes Santa to first enter the basement? diff --git a/day1/Makefile b/day1/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day1/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day1/day1.c b/day1/day1.c new file mode 100644 index 0000000..dbd188d --- /dev/null +++ b/day1/day1.c @@ -0,0 +1,21 @@ +#include + +int main() { + int ch, floor = 0, pos = 0, first_basement = 1; + while ((ch = getchar()) != EOF) { + pos += 1; + switch(ch) { + case '(': + floor += 1; + break; + case ')': + floor -= 1; + } + if (floor == -1 && first_basement) { + printf("In the basement at position: %d\n", pos); + first_basement = 0; + } + } + printf("Final floor: %d\n", floor); + return 0; +} diff --git a/day1/day1.input b/day1/day1.input new file mode 100644 index 0000000..becde71 --- /dev/null +++ b/day1/day1.input @@ -0,0 +1 @@ +((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()()(()(((()(((((())()))()((()(()))()((()((((())((((())(()(((())()()(()()()()()(())((((())((())(()()))()((((())))((((()())()((((())((()())((())(())(((((()((((()(((()((((())(()(((()()))()))((((((()((())()())))(((()(()))(()()(()(((()(()))((()()()())((()()()(((())())()())())())((()))(()(()))(((((()(()(())((()(())(())()((((()())()))((((())(())((())())((((()(((())(())((()()((((()((((((()(())()()(()(()()((((()))(())()())()))(())))(())))())()()(())(()))()((()(()(())()()))(()())))))(()))(()()))(())(((((()(()(()()((())()())))))((())())((())(()(())((()))(())(((()((((((((()()()(()))()()(((()))()((()()(())(())())()(()(())))(((((()(())(())(()))))())()))(()))()(()(((((((()((((())))())())())())()((((((((((((((()()((((((()()()())())()())())())(())(())))())((()())((()(()))))))()))))))))))))))))())((())((())()()))))))(((()((()(()()))((())(()()))()()())))(())))))))(()(((())))())()())))()()(())()))()(()))())((()()))))(()))))()))(()()(())))))))()(((()))))()(()))(())())))))()))((()))((()))())(())))))))))((((())()))()))()))())(())()()(())))())))(()())()))((()()(())))(())((((((()(())((()(((()(()()(())))()))))))()))()(()((()))()(()))(()(((())((((())())(())(()))))))))())))))))())())))))())))))()()(((())()(()))))))))())))))(())()()()))()))()))(()(())()()())())))))))())()(()(()))))()()()))))())(()))))()()))))()())))))(((())()()))(()))))))))))()()))))()()()))))(()())())()()())()(()))))()(()))(())))))))(((((())(())())()()))()()))(())))))()(()))))(())(()()))()())()))()))()))()))))())()()))())())))(()))(()))))))())()(((())()))))))))()))()())))())))())))()))))))))))()()))(()()))))))(())()(()))))())(()))))(()))))(()())))))())())()()))))())()))))))))(()))))()))))))()(()())))))))()))())))())))())))())))))))())(()()))))))(()())())))()())()))))))))))))))())))()(())))()))())()()(())(()()))(())))())()())(()(()(()))))())))))))))))())(()))()))()))))(())()())()())))))))))))()()))))))))))))())())))))(()())))))))))))())(())))()))))))))())())(()))()))(())))()))()()(())()))))))()((((())()))())())))))()))()))))((()())()))))())))(())))))))))))))))))()))))()()())()))()()))))())()))((()())))())))(()))(()())))))))()))()))))(())))))))(())))))())()()(()))())()))()()))))())()()))))())()))())))))))(()))))()())()))))))))(()))())))(()))()))))(())()))())())(())())())))))))((((())))))()))()))()())()(())))()))()))()())(()())()()(()())()))))())())))))(()))()))))())(()()(())))))(())()()((())())))))(())(())))))))())))))))))()(())))))))()())())())()(()))))))))(()))))))))())()()))()(()))))))()))))))())))))))(())))()()(())()())))))(((())))()((())()))())))(()()))())(())())))()(((()())))))()(()()())))()()(()()(()()))())()(()()()))())()()))()())(()))))())))))())))(())()()))))(()))))(())(()))(())))))()()))()))))())()))()()(())())))((()))())()))))))()()))))((()(()))))()()))))))())))))())(()((()())))))))))))()())())))()))(()))))))(()))(())()())))(()))))))))())()()()()))))(()())))))))((())))()))(()))(())(())()())()))))))))(())))())))(()))()()))(()()))(()))())))()(())))())((()((()(())))((())))()))))((((())())()())))(())))()))))))())(()()((())))())()(()())))))(()())()))())))))))((())())))))))(()(()))())()()(()()(((()(((()())))))()))))))()(())(()()((()()(())()()))())()())()))()())())())))))))(((())))))))()()))))))(((())()))(()()))(()()))))(()(()()((((())()())((()()))))(()(())))))()((()()()())()()((()((()()))(()))(((()()()))(((())))()(((())()))))))((()(())())))(()())(((((()(()))(()((()))(()())()))))(()(()))()(()))(())(((())(()()))))()()))(((()))))(()()()()))())))((()()()(())()))()))))()()))()))))))((((((()()()))))())((()()(((()))))(()(())(()()())())())))()(((()()))(())((())))(()))(()()()())((())())())(()))))()))()((()(())()(()()(())(()))(())()))(())(()))))(())(())())(()()(()((()()((())))((()))()((())))(((()()()()((((()))(()()))()()()(((())((())())(()()(()()()))()((())(())()))())(((()()(())))()((()()())()())(()(())())(((())(())())((())(())()(((()()))(())))((())(()())())(())((()()()((((((())))((()(((((())()))()))(())(()()))()))(())()()))(())((()()())()()(()))())()((())))()((()()())((((()())((())())())((()((()))()))((())((()()(()((()()(((())(()()))))((()((())()(((())(()((())())((())(()((((((())())()(()())()(())(((())((((((()(())(()((()()()((()()(()()()())))()()(((((()()))()((((((()))()(()(()(()(((()())((()))())()((()))(())))()))()()))())()()))())((((())(()(()))(((((((())(((()(((((()(((()()((((())(((())())))(()()()(()(()))()))((((((()))((()(((()(())((()((((()((((((())(((((())))(((()(()))))(((()(((())()((())(()((()))(((()()(((())((((()(()(((((()))(((()(((((((()(()()()(()(()(()()())(())(((((()(())())()())(()(()(()))()(()()()())(()()(()((()))()((())())()(()))((())(()))()(()))()(((()(()(()((((((()()()()())()(((((()()(((()()()((()(((((()))((((((((()()()(((((()))))))(()()()(())(()))(()()))))(())()))(((((()(((((()()(()(()())(((()))((((()((()(()(()((()(()((())))()(((()((()))((()))(((((((((()((()((()(())))()((((()((()()))((())(((()(((((()()(()(()()((()(()()()(((((((())())()())))))((((()()(()))()))(()((())()(()(((((((((()()(((()(()())(()((()())((())())((((()(((()(((()((((()((()((((()(()((((((())((((((((((((()()(()()((((((((((((((()((()()))()((((((((((((())((((()(()())((()(()(()))()(((((()()(((()()))()())(())((()(((((()((())(((((()((()(((((()))()()((((())()((((())(((((((((()(())(()(())))())(()((())(((())(())(())())(()(()(())()()((()((())()(((()(((((()(())))()(((()((())))((()()()(((()(((()((()(()(())(()((()())(()(()(((()(((((((((())(()((((()()))(()((((()()()()(((()((((((((()(()()((((((()(()()(()((()((((((((((()()(((((((()())(())))(((()()))(((((()((()()())(()()((((())((()((((()))))(())((()(()()(((()(()(((()((((()(((((()))())())(()((())()))(((()())((())((())((((()((()((((((())(()((((()()))((((((())()(()))((()(((())((((((((((()()(((((()(((((()((()()()((((())))(()))()((()(())()()((()((((((((((()((())(())(((((()(()(()()))((((()((((()()((()(((()(((((((((()(()((()((()))((((((()(((())()()((()(((((((()())))()()(()((()((()()(((()(()()()()((((()((())((((()(((((((((()(((()()(((()(()(((()(((()((())()(()((()(()(()(()))()(((()))(()((((()((())((((())((((((())(()))(()((((())((()(()((((((((()()((((((()(()(()()()(())((()((()()(((()(((((((()()((()(((((((()))(((((()(((()(()()()(()(((()((()()((())(()(((((((((()(()((()((((((()()((())()))(((((()((())()())()(((((((((((()))((((()()()()())(()()(()(()()))()))(()))(()(((()()))())(()(()))()()((())(()())()())()(()))()))(()()(()((((((())((()(((((((((((()(())()((()(()((()((()(()((()((((((((((()()())((())()(())))((())()())()(((((()(()())((((()((()(())(()))(((())()((()))(((((())(()))()()(()))(((())((((()((((()(())))(((((((()))))())()())(())((())()(()()((()(()))()(()()(()()((()())((())((()()))((((()))()()))(()()(())()()(((((()(())((()((((()))()))(()())())(((()()(()()))(())))))(()))((())(((((()((((()))()((((()))()((())(((())))(((()())))((()(()()(( diff --git a/day1/day1.readme b/day1/day1.readme new file mode 100644 index 0000000..0da69d3 --- /dev/null +++ b/day1/day1.readme @@ -0,0 +1,34 @@ +--- Day 1: Not Quite Lisp --- + +Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December 25th. + +Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! + +Here's an easy puzzle to warm you up. + +Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time. + +An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor. + +The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors. + +For example: + + - (()) and ()() both result in floor 0. + - ((( and (()(()( both result in floor 3. + - ))((((( also results in floor 3. + - ()) and ))( both result in floor -1 (the first basement level). + - ))) and )())()) both result in floor -3. + +To what floor do the instructions take Santa? + +--- Part Two --- + +Now, given the same instructions, find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on. + +For example: + + - ) causes him to enter the basement at character position 1. + - ()()) causes him to enter the basement at character position 5. + +What is the position of the character that causes Santa to first enter the basement? diff --git a/day2.c b/day2.c deleted file mode 100644 index d02526f..0000000 --- a/day2.c +++ /dev/null @@ -1,56 +0,0 @@ -#include - -int min2(int a, int b) { - if (a < b) return a; - return b; -} -int min3(int a, int b, int c) { - return min2(min2(a, b), c); -} - -int readsides(int* length, int* width, int* height) { - return scanf("%dx%dx%d", length, width, height); -} - -void calcsides(int length, int width, int height, int* side1, int* side2, int* side3) { - (*side1) = length * width; - (*side2) = width * height; - (*side3) = height * length; -} - -void calcperi(int edge1, int edge2, int* peri) { - (*peri) = 2 * edge1 + 2 * edge2; -} - -void calcarea(int side1, int side2, int side3, int* area) { - (*area) = 2*side1 + 2*side2 + 2*side3 + min3(side1, side2, side3); -} - -void calcribbon(int length, int width, int height, int* ribbon) { - int bow, wrap; - int side1, side2, side3; - calcperi(length, width, &side1); - calcperi(width, height, &side2); - calcperi(height, length, &side3); - wrap = min3(side1, side2, side3); - bow = length * width * height; - (*ribbon) = wrap + bow; -} - -int main() { - int length, width, height; - int side1, side2, side3; - int area, totalarea = 0; - int ribbon, totalribbon = 0; - - while (readsides(&length, &width, &height) > 0) { - calcsides(length, width, height, &side1, &side2, &side3); - calcarea(side1, side2, side3, &area); - calcribbon(length, width, height, &ribbon); - totalarea += area; - totalribbon += ribbon; - } - - printf("Total area: %d\nTotal ribbon: %d\n", totalarea, totalribbon); - return 0; -} diff --git a/day2.input b/day2.input deleted file mode 100644 index b52434e..0000000 --- a/day2.input +++ /dev/null @@ -1,1000 +0,0 @@ -4x23x21 -22x29x19 -11x4x11 -8x10x5 -24x18x16 -11x25x22 -2x13x20 -24x15x14 -14x22x2 -30x7x3 -30x22x25 -29x9x9 -29x29x26 -14x3x16 -1x10x26 -29x2x30 -30x10x25 -10x26x20 -1x2x18 -25x18x5 -21x3x24 -2x5x7 -22x11x21 -11x8x8 -16x18x2 -13x3x8 -1x16x19 -19x16x12 -21x15x1 -29x9x4 -27x10x8 -2x7x27 -2x20x23 -24x11x5 -2x8x27 -10x28x10 -24x11x10 -19x2x12 -27x5x10 -1x14x25 -5x14x30 -15x26x12 -23x20x22 -5x12x1 -9x26x9 -23x25x5 -28x16x19 -17x23x17 -2x27x20 -18x27x13 -16x7x18 -22x7x29 -17x28x6 -9x22x17 -10x5x6 -14x2x12 -25x5x6 -26x9x10 -19x21x6 -19x4x27 -23x16x14 -21x17x29 -24x18x10 -7x19x6 -14x15x10 -9x10x19 -20x18x4 -11x14x8 -30x15x9 -25x12x24 -3x12x5 -12x21x28 -8x23x10 -18x26x8 -17x1x8 -2x29x15 -3x13x28 -23x20x11 -27x25x6 -19x21x3 -30x22x27 -28x24x4 -26x18x21 -11x7x16 -22x27x6 -27x5x26 -4x10x4 -4x2x27 -2x3x26 -26x29x19 -30x26x24 -8x25x12 -16x17x5 -13x2x3 -1x30x22 -20x9x1 -24x26x19 -26x18x1 -18x29x24 -1x6x9 -20x27x2 -3x22x21 -4x16x8 -29x18x16 -7x16x23 -13x8x14 -19x25x10 -23x29x6 -23x21x1 -22x26x10 -14x4x2 -18x29x17 -9x4x18 -7x22x9 -19x5x26 -27x29x19 -7x13x14 -19x10x1 -6x22x3 -12x21x5 -24x20x12 -28x2x11 -16x18x23 -2x13x25 -11x7x17 -27x21x4 -2x10x25 -22x16x17 -23x22x15 -17x13x13 -23x24x26 -27x18x24 -24x7x28 -30x12x15 -14x28x19 -2x15x29 -12x13x5 -17x22x21 -27x10x27 -17x6x25 -22x2x1 -1x10x9 -9x7x2 -30x28x3 -28x11x10 -8x23x15 -23x4x20 -12x5x4 -13x17x14 -28x11x2 -21x11x29 -10x23x22 -27x23x14 -7x15x23 -20x2x13 -8x21x4 -10x20x11 -23x28x11 -21x22x25 -23x11x17 -2x29x10 -28x16x5 -30x26x10 -17x24x16 -26x27x25 -14x13x25 -22x27x5 -24x15x12 -5x21x25 -4x27x1 -25x4x10 -15x13x1 -21x23x7 -8x3x4 -10x5x7 -9x13x30 -2x2x30 -26x4x29 -5x14x14 -2x27x9 -22x16x1 -4x23x5 -13x7x26 -2x12x10 -12x7x22 -26x30x26 -28x16x28 -15x19x11 -4x18x1 -20x14x24 -6x10x22 -9x20x3 -14x9x27 -26x17x9 -10x30x28 -6x3x29 -4x16x28 -8x24x11 -23x10x1 -11x7x7 -29x6x15 -13x25x12 -29x14x3 -26x22x21 -8x3x11 -27x13x25 -27x6x2 -8x11x7 -25x12x9 -24x30x12 -13x1x30 -25x23x16 -9x13x29 -29x26x16 -11x15x9 -11x23x6 -15x27x28 -27x24x21 -6x24x1 -25x25x5 -11x1x26 -21x4x24 -10x5x12 -4x30x13 -24x22x5 -26x7x21 -23x3x17 -22x18x2 -25x1x14 -23x25x30 -8x7x7 -30x19x8 -17x6x15 -2x11x20 -8x3x22 -23x14x26 -8x22x25 -27x1x2 -10x26x2 -28x30x7 -5x30x7 -27x16x30 -28x29x1 -8x25x18 -20x12x29 -9x19x9 -7x25x15 -25x18x18 -11x8x2 -4x20x6 -18x5x20 -2x3x29 -25x26x22 -18x25x26 -9x12x16 -18x7x27 -17x20x9 -6x29x26 -17x7x19 -21x7x5 -29x15x12 -22x4x1 -11x12x11 -26x30x4 -12x24x13 -13x8x3 -26x25x3 -21x26x10 -14x9x26 -20x1x7 -11x12x3 -12x11x4 -11x15x30 -17x6x25 -20x22x3 -1x16x17 -11x5x20 -12x12x7 -2x14x10 -14x27x3 -14x16x18 -21x28x24 -14x20x1 -29x14x1 -10x10x9 -25x23x4 -17x15x14 -9x20x26 -16x2x17 -13x28x25 -16x1x11 -19x16x8 -20x21x2 -27x9x22 -24x18x3 -23x30x6 -4x18x3 -30x15x8 -27x20x19 -28x29x26 -2x21x18 -1x23x30 -1x9x12 -4x11x30 -1x28x4 -17x10x10 -12x14x6 -8x9x24 -8x3x3 -29x8x20 -26x29x2 -29x25x25 -11x17x23 -6x30x21 -13x18x29 -2x10x8 -29x29x27 -27x15x15 -16x17x30 -3x3x22 -21x12x6 -22x1x5 -30x8x20 -6x28x13 -11x2x23 -14x18x27 -6x26x13 -10x24x24 -4x24x6 -20x8x3 -23x11x5 -29x5x24 -14x15x22 -21x17x13 -10x10x8 -1x11x23 -21x19x24 -19x9x13 -21x26x28 -25x11x28 -2x17x1 -18x9x8 -5x21x6 -12x5x2 -23x8x15 -30x16x24 -7x9x27 -16x30x7 -2x21x28 -5x10x6 -8x7x1 -28x13x5 -11x5x14 -26x22x29 -23x15x13 -14x2x16 -22x21x9 -4x20x3 -18x17x19 -12x7x9 -6x12x25 -3x30x27 -8x19x22 -1x9x27 -23x20x12 -14x7x29 -9x12x12 -30x2x6 -15x7x16 -19x13x18 -11x8x13 -16x5x3 -19x26x24 -26x8x21 -21x20x7 -15x1x25 -29x15x21 -22x17x7 -16x17x10 -6x12x24 -8x13x27 -30x25x14 -25x7x10 -15x2x2 -18x15x19 -18x13x24 -19x30x1 -17x1x3 -26x21x15 -10x10x18 -9x16x6 -29x7x30 -11x10x30 -6x11x2 -7x29x23 -13x2x30 -25x27x13 -5x15x21 -4x8x30 -15x27x11 -27x1x6 -2x24x11 -16x20x19 -25x28x20 -6x8x4 -27x16x11 -1x5x27 -12x19x26 -18x24x14 -4x25x17 -24x24x26 -28x3x18 -8x20x28 -22x7x21 -24x5x28 -23x30x29 -25x16x27 -28x10x30 -9x2x4 -30x2x23 -21x9x23 -27x4x26 -2x23x16 -24x26x30 -26x1x30 -10x4x28 -11x29x12 -28x13x30 -24x10x28 -8x12x12 -19x27x11 -11x28x7 -14x6x3 -6x27x5 -6x17x14 -24x24x17 -18x23x14 -17x5x7 -11x4x23 -5x1x17 -26x15x24 -3x9x24 -5x3x15 -5x20x19 -5x21x2 -13x5x30 -19x6x24 -19x17x6 -23x7x13 -28x23x13 -9x1x6 -15x12x16 -21x19x9 -25x5x5 -9x7x9 -6x5x8 -3x11x18 -23x25x11 -25x4x6 -4x27x1 -4x3x3 -30x11x5 -9x17x12 -15x6x24 -10x22x15 -29x27x9 -20x21x11 -18x10x5 -11x2x2 -9x8x8 -1x26x21 -11x11x16 -2x18x30 -29x27x24 -27x8x18 -19x3x17 -30x21x26 -25x13x25 -20x22x1 -10x1x12 -11x17x15 -29x11x30 -17x30x27 -21x22x17 -13x6x22 -22x16x12 -27x18x19 -4x13x6 -27x29x10 -3x23x10 -26x16x24 -18x26x20 -11x28x16 -21x6x15 -9x26x17 -8x15x8 -3x7x10 -2x28x8 -1x2x24 -7x8x9 -19x4x22 -11x20x9 -12x22x16 -26x8x19 -13x28x24 -4x10x16 -12x8x10 -14x24x24 -19x19x28 -29x1x15 -10x5x14 -20x19x23 -10x7x12 -1x7x13 -5x12x13 -25x21x8 -22x28x8 -7x9x4 -3x20x15 -15x27x19 -18x24x12 -16x10x16 -22x19x8 -15x4x3 -9x30x25 -1x1x6 -24x4x25 -13x18x29 -10x2x8 -21x1x17 -29x14x22 -17x29x11 -10x27x16 -25x16x15 -14x2x17 -12x27x3 -14x17x25 -24x4x1 -18x28x18 -9x14x26 -28x24x17 -1x26x12 -2x18x20 -12x19x22 -19x25x20 -5x17x27 -17x29x16 -29x19x11 -16x2x4 -23x24x1 -19x18x3 -28x14x6 -18x5x23 -9x24x12 -15x4x6 -15x7x24 -22x15x8 -22x1x22 -6x4x22 -26x1x30 -8x21x27 -7x1x11 -9x8x18 -20x27x12 -26x23x20 -26x22x30 -24x3x16 -8x24x28 -13x28x5 -4x29x23 -22x5x8 -20x22x3 -9x9x17 -28x3x30 -10x13x10 -10x25x13 -9x20x3 -1x21x25 -24x21x15 -21x5x14 -13x8x20 -29x17x3 -5x17x28 -16x12x7 -23x1x24 -4x24x29 -23x25x14 -8x27x2 -23x11x13 -13x4x5 -24x1x26 -21x1x23 -10x12x12 -21x29x25 -27x25x30 -24x23x4 -1x30x23 -29x28x14 -4x11x30 -9x25x10 -17x11x6 -14x29x30 -23x5x5 -25x18x21 -8x7x1 -27x11x3 -5x10x8 -11x1x11 -16x17x26 -15x22x19 -16x9x6 -18x13x27 -26x4x22 -1x20x21 -6x14x29 -11x7x6 -1x23x7 -12x19x13 -18x21x25 -15x17x20 -23x8x9 -15x9x26 -9x12x9 -12x13x14 -27x26x7 -11x19x22 -16x12x21 -10x30x28 -21x2x7 -12x9x18 -7x17x14 -13x17x17 -3x21x10 -30x9x15 -2x8x15 -15x12x10 -23x26x9 -29x30x10 -30x22x17 -17x26x30 -27x26x20 -17x28x17 -30x12x16 -7x23x15 -30x15x19 -13x19x10 -22x10x4 -17x23x10 -2x28x18 -27x21x28 -24x26x5 -6x23x25 -17x4x16 -14x1x13 -23x21x11 -14x15x30 -26x13x10 -30x19x25 -26x6x26 -9x16x29 -15x2x24 -13x3x20 -23x12x30 -22x23x23 -8x21x2 -18x28x5 -21x27x14 -29x28x23 -12x30x28 -17x16x3 -5x19x11 -28x22x22 -1x4x28 -10x10x14 -18x15x7 -18x11x1 -12x7x16 -10x22x24 -27x25x6 -19x29x25 -10x1x26 -26x27x30 -4x23x19 -24x19x4 -21x11x14 -4x13x27 -9x1x11 -16x20x8 -4x3x11 -1x16x12 -14x6x30 -8x1x10 -11x18x7 -29x28x30 -4x21x8 -3x21x4 -6x1x5 -26x18x3 -28x27x27 -17x3x12 -6x1x22 -23x12x28 -12x13x2 -11x2x13 -7x1x28 -27x6x25 -14x14x3 -14x11x20 -2x27x7 -22x24x23 -7x15x20 -30x6x17 -20x23x25 -18x16x27 -2x9x6 -9x18x19 -20x11x22 -11x16x19 -14x29x23 -14x9x20 -8x10x12 -18x17x6 -28x7x16 -12x19x28 -5x3x16 -1x25x10 -4x14x10 -9x6x3 -15x27x28 -13x26x14 -21x8x25 -29x10x20 -14x26x30 -25x13x28 -1x15x23 -6x20x21 -18x2x1 -22x25x16 -23x25x17 -2x14x21 -14x25x16 -12x17x6 -19x29x15 -25x9x6 -19x17x13 -24x22x5 -19x4x13 -10x18x6 -6x25x6 -23x24x20 -8x22x13 -25x10x29 -5x12x25 -20x5x11 -7x16x29 -29x24x22 -28x20x1 -10x27x10 -6x9x27 -26x15x30 -26x3x19 -20x11x3 -26x1x29 -6x23x4 -6x13x21 -9x23x25 -15x1x10 -29x12x13 -7x8x24 -29x30x27 -3x29x19 -14x16x17 -4x8x27 -26x17x8 -10x27x17 -11x28x17 -17x16x27 -1x8x22 -6x30x16 -7x30x22 -20x12x3 -18x10x2 -20x21x26 -11x1x17 -9x15x15 -19x14x30 -24x22x20 -11x26x23 -14x3x23 -1x28x29 -29x20x4 -1x4x20 -12x26x8 -14x11x14 -14x19x13 -15x13x24 -16x7x26 -11x20x11 -5x24x26 -24x25x7 -21x3x14 -24x29x20 -7x12x1 -16x17x4 -29x16x21 -28x8x17 -11x30x25 -1x26x23 -25x19x28 -30x24x5 -26x29x15 -4x25x23 -14x25x19 -29x10x7 -29x29x28 -19x13x24 -21x28x5 -8x15x24 -1x10x12 -2x26x6 -14x14x4 -10x16x27 -9x17x25 -25x8x7 -1x9x28 -10x8x17 -4x12x1 -17x26x29 -23x12x26 -2x21x22 -18x23x13 -1x14x5 -25x27x26 -4x30x30 -5x13x2 -17x9x6 -28x18x28 -7x30x2 -28x22x17 -14x15x14 -10x14x19 -6x15x22 -27x4x17 -28x21x6 -19x29x26 -6x17x17 -20x13x16 -25x4x1 -2x9x5 -30x3x1 -24x21x2 -14x19x12 -22x5x23 -14x4x21 -10x2x17 -3x14x10 -17x5x3 -22x17x13 -5x19x3 -29x22x6 -12x28x3 -9x21x25 -10x2x14 -13x26x7 -18x23x2 -9x14x17 -21x3x13 -13x23x9 -1x20x4 -11x4x1 -19x5x30 -9x9x29 -26x29x14 -1x4x10 -7x27x30 -8x3x23 -1x27x27 -7x27x27 -1x26x16 -29x16x14 -18x6x12 -24x24x24 -26x2x19 -15x17x4 -11x7x14 -14x19x10 -9x10x1 -14x17x9 -20x19x13 -25x20x8 -24x20x21 -26x30x2 -24x2x10 -28x4x13 -27x17x11 -15x3x8 -11x29x10 -26x15x16 -4x28x22 -7x5x22 -10x28x9 -6x28x13 -10x5x6 -20x12x6 -25x30x30 -17x16x14 -14x20x3 -16x10x8 -9x28x14 -16x12x12 -11x13x25 -21x16x28 -10x3x18 -5x9x20 -17x23x5 -3x13x16 -29x30x17 -2x2x8 -15x8x30 -20x1x16 -23x10x29 -4x5x4 -6x18x12 -26x10x22 -21x10x17 -26x12x29 -7x20x21 -18x9x15 -10x23x20 -20x1x27 -10x10x3 -25x12x23 -30x11x15 -16x22x3 -22x10x11 -15x10x20 -2x20x17 -20x20x1 -24x16x4 -23x27x7 -7x27x22 -24x16x8 -20x11x25 -30x28x11 -21x6x24 -15x2x9 -16x30x24 -21x27x9 -7x19x8 -24x13x28 -12x26x28 -16x21x11 -25x5x13 -23x3x17 -23x1x17 -4x17x18 -17x13x18 -25x12x19 -17x4x19 -4x21x26 -6x28x1 -23x22x15 -6x23x12 -21x17x9 -30x4x23 -2x19x21 -28x24x7 -19x24x14 -13x20x26 -19x24x29 -8x26x3 -16x12x14 -17x4x21 -8x4x20 -13x27x17 -9x21x1 -29x25x6 -7x9x26 -13x25x5 -6x9x21 -12x10x11 -30x28x21 -15x6x2 -8x18x19 -26x20x24 -26x17x14 -27x8x1 -19x19x18 -25x24x27 -14x29x15 -22x26x1 -14x17x9 -2x6x23 -29x7x5 -14x16x19 -14x21x18 -10x15x23 -21x29x14 -20x29x30 -23x11x5 diff --git a/day2.readme b/day2.readme deleted file mode 100644 index d329683..0000000 --- a/day2.readme +++ /dev/null @@ -1,25 +0,0 @@ ---- Day 2: I Was Told There Would Be No Math --- - -The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as much as they need. - -Fortunately, every present is a box (a perfect right rectangular prism), which makes calculating the required wrapping paper for each gift a little easier: find the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each present: the area of the smallest side. - -For example: - - - A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping paper plus 6 square feet of slack, for a total of 58 square feet. - - A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping paper plus 1 square foot of slack, for a total of 43 square feet. - -All numbers in the elves' list are in feet. How many total square feet of wrapping paper should they order? - ---- Part Two --- - -The elves are also running low on ribbon. Ribbon is all the same width, so they only have to worry about the length they need to order, which they would again like to be exact. - -The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face. Each present also requires a bow made out of ribbon as well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present. Don't ask how they tie the bow, though; they'll never tell. - -For example: - - - A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet. - - A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 feet. - -How many total feet of ribbon should they order? diff --git a/day2/Makefile b/day2/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day2/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day2/day2.c b/day2/day2.c new file mode 100644 index 0000000..d02526f --- /dev/null +++ b/day2/day2.c @@ -0,0 +1,56 @@ +#include + +int min2(int a, int b) { + if (a < b) return a; + return b; +} +int min3(int a, int b, int c) { + return min2(min2(a, b), c); +} + +int readsides(int* length, int* width, int* height) { + return scanf("%dx%dx%d", length, width, height); +} + +void calcsides(int length, int width, int height, int* side1, int* side2, int* side3) { + (*side1) = length * width; + (*side2) = width * height; + (*side3) = height * length; +} + +void calcperi(int edge1, int edge2, int* peri) { + (*peri) = 2 * edge1 + 2 * edge2; +} + +void calcarea(int side1, int side2, int side3, int* area) { + (*area) = 2*side1 + 2*side2 + 2*side3 + min3(side1, side2, side3); +} + +void calcribbon(int length, int width, int height, int* ribbon) { + int bow, wrap; + int side1, side2, side3; + calcperi(length, width, &side1); + calcperi(width, height, &side2); + calcperi(height, length, &side3); + wrap = min3(side1, side2, side3); + bow = length * width * height; + (*ribbon) = wrap + bow; +} + +int main() { + int length, width, height; + int side1, side2, side3; + int area, totalarea = 0; + int ribbon, totalribbon = 0; + + while (readsides(&length, &width, &height) > 0) { + calcsides(length, width, height, &side1, &side2, &side3); + calcarea(side1, side2, side3, &area); + calcribbon(length, width, height, &ribbon); + totalarea += area; + totalribbon += ribbon; + } + + printf("Total area: %d\nTotal ribbon: %d\n", totalarea, totalribbon); + return 0; +} diff --git a/day2/day2.input b/day2/day2.input new file mode 100644 index 0000000..b52434e --- /dev/null +++ b/day2/day2.input @@ -0,0 +1,1000 @@ +4x23x21 +22x29x19 +11x4x11 +8x10x5 +24x18x16 +11x25x22 +2x13x20 +24x15x14 +14x22x2 +30x7x3 +30x22x25 +29x9x9 +29x29x26 +14x3x16 +1x10x26 +29x2x30 +30x10x25 +10x26x20 +1x2x18 +25x18x5 +21x3x24 +2x5x7 +22x11x21 +11x8x8 +16x18x2 +13x3x8 +1x16x19 +19x16x12 +21x15x1 +29x9x4 +27x10x8 +2x7x27 +2x20x23 +24x11x5 +2x8x27 +10x28x10 +24x11x10 +19x2x12 +27x5x10 +1x14x25 +5x14x30 +15x26x12 +23x20x22 +5x12x1 +9x26x9 +23x25x5 +28x16x19 +17x23x17 +2x27x20 +18x27x13 +16x7x18 +22x7x29 +17x28x6 +9x22x17 +10x5x6 +14x2x12 +25x5x6 +26x9x10 +19x21x6 +19x4x27 +23x16x14 +21x17x29 +24x18x10 +7x19x6 +14x15x10 +9x10x19 +20x18x4 +11x14x8 +30x15x9 +25x12x24 +3x12x5 +12x21x28 +8x23x10 +18x26x8 +17x1x8 +2x29x15 +3x13x28 +23x20x11 +27x25x6 +19x21x3 +30x22x27 +28x24x4 +26x18x21 +11x7x16 +22x27x6 +27x5x26 +4x10x4 +4x2x27 +2x3x26 +26x29x19 +30x26x24 +8x25x12 +16x17x5 +13x2x3 +1x30x22 +20x9x1 +24x26x19 +26x18x1 +18x29x24 +1x6x9 +20x27x2 +3x22x21 +4x16x8 +29x18x16 +7x16x23 +13x8x14 +19x25x10 +23x29x6 +23x21x1 +22x26x10 +14x4x2 +18x29x17 +9x4x18 +7x22x9 +19x5x26 +27x29x19 +7x13x14 +19x10x1 +6x22x3 +12x21x5 +24x20x12 +28x2x11 +16x18x23 +2x13x25 +11x7x17 +27x21x4 +2x10x25 +22x16x17 +23x22x15 +17x13x13 +23x24x26 +27x18x24 +24x7x28 +30x12x15 +14x28x19 +2x15x29 +12x13x5 +17x22x21 +27x10x27 +17x6x25 +22x2x1 +1x10x9 +9x7x2 +30x28x3 +28x11x10 +8x23x15 +23x4x20 +12x5x4 +13x17x14 +28x11x2 +21x11x29 +10x23x22 +27x23x14 +7x15x23 +20x2x13 +8x21x4 +10x20x11 +23x28x11 +21x22x25 +23x11x17 +2x29x10 +28x16x5 +30x26x10 +17x24x16 +26x27x25 +14x13x25 +22x27x5 +24x15x12 +5x21x25 +4x27x1 +25x4x10 +15x13x1 +21x23x7 +8x3x4 +10x5x7 +9x13x30 +2x2x30 +26x4x29 +5x14x14 +2x27x9 +22x16x1 +4x23x5 +13x7x26 +2x12x10 +12x7x22 +26x30x26 +28x16x28 +15x19x11 +4x18x1 +20x14x24 +6x10x22 +9x20x3 +14x9x27 +26x17x9 +10x30x28 +6x3x29 +4x16x28 +8x24x11 +23x10x1 +11x7x7 +29x6x15 +13x25x12 +29x14x3 +26x22x21 +8x3x11 +27x13x25 +27x6x2 +8x11x7 +25x12x9 +24x30x12 +13x1x30 +25x23x16 +9x13x29 +29x26x16 +11x15x9 +11x23x6 +15x27x28 +27x24x21 +6x24x1 +25x25x5 +11x1x26 +21x4x24 +10x5x12 +4x30x13 +24x22x5 +26x7x21 +23x3x17 +22x18x2 +25x1x14 +23x25x30 +8x7x7 +30x19x8 +17x6x15 +2x11x20 +8x3x22 +23x14x26 +8x22x25 +27x1x2 +10x26x2 +28x30x7 +5x30x7 +27x16x30 +28x29x1 +8x25x18 +20x12x29 +9x19x9 +7x25x15 +25x18x18 +11x8x2 +4x20x6 +18x5x20 +2x3x29 +25x26x22 +18x25x26 +9x12x16 +18x7x27 +17x20x9 +6x29x26 +17x7x19 +21x7x5 +29x15x12 +22x4x1 +11x12x11 +26x30x4 +12x24x13 +13x8x3 +26x25x3 +21x26x10 +14x9x26 +20x1x7 +11x12x3 +12x11x4 +11x15x30 +17x6x25 +20x22x3 +1x16x17 +11x5x20 +12x12x7 +2x14x10 +14x27x3 +14x16x18 +21x28x24 +14x20x1 +29x14x1 +10x10x9 +25x23x4 +17x15x14 +9x20x26 +16x2x17 +13x28x25 +16x1x11 +19x16x8 +20x21x2 +27x9x22 +24x18x3 +23x30x6 +4x18x3 +30x15x8 +27x20x19 +28x29x26 +2x21x18 +1x23x30 +1x9x12 +4x11x30 +1x28x4 +17x10x10 +12x14x6 +8x9x24 +8x3x3 +29x8x20 +26x29x2 +29x25x25 +11x17x23 +6x30x21 +13x18x29 +2x10x8 +29x29x27 +27x15x15 +16x17x30 +3x3x22 +21x12x6 +22x1x5 +30x8x20 +6x28x13 +11x2x23 +14x18x27 +6x26x13 +10x24x24 +4x24x6 +20x8x3 +23x11x5 +29x5x24 +14x15x22 +21x17x13 +10x10x8 +1x11x23 +21x19x24 +19x9x13 +21x26x28 +25x11x28 +2x17x1 +18x9x8 +5x21x6 +12x5x2 +23x8x15 +30x16x24 +7x9x27 +16x30x7 +2x21x28 +5x10x6 +8x7x1 +28x13x5 +11x5x14 +26x22x29 +23x15x13 +14x2x16 +22x21x9 +4x20x3 +18x17x19 +12x7x9 +6x12x25 +3x30x27 +8x19x22 +1x9x27 +23x20x12 +14x7x29 +9x12x12 +30x2x6 +15x7x16 +19x13x18 +11x8x13 +16x5x3 +19x26x24 +26x8x21 +21x20x7 +15x1x25 +29x15x21 +22x17x7 +16x17x10 +6x12x24 +8x13x27 +30x25x14 +25x7x10 +15x2x2 +18x15x19 +18x13x24 +19x30x1 +17x1x3 +26x21x15 +10x10x18 +9x16x6 +29x7x30 +11x10x30 +6x11x2 +7x29x23 +13x2x30 +25x27x13 +5x15x21 +4x8x30 +15x27x11 +27x1x6 +2x24x11 +16x20x19 +25x28x20 +6x8x4 +27x16x11 +1x5x27 +12x19x26 +18x24x14 +4x25x17 +24x24x26 +28x3x18 +8x20x28 +22x7x21 +24x5x28 +23x30x29 +25x16x27 +28x10x30 +9x2x4 +30x2x23 +21x9x23 +27x4x26 +2x23x16 +24x26x30 +26x1x30 +10x4x28 +11x29x12 +28x13x30 +24x10x28 +8x12x12 +19x27x11 +11x28x7 +14x6x3 +6x27x5 +6x17x14 +24x24x17 +18x23x14 +17x5x7 +11x4x23 +5x1x17 +26x15x24 +3x9x24 +5x3x15 +5x20x19 +5x21x2 +13x5x30 +19x6x24 +19x17x6 +23x7x13 +28x23x13 +9x1x6 +15x12x16 +21x19x9 +25x5x5 +9x7x9 +6x5x8 +3x11x18 +23x25x11 +25x4x6 +4x27x1 +4x3x3 +30x11x5 +9x17x12 +15x6x24 +10x22x15 +29x27x9 +20x21x11 +18x10x5 +11x2x2 +9x8x8 +1x26x21 +11x11x16 +2x18x30 +29x27x24 +27x8x18 +19x3x17 +30x21x26 +25x13x25 +20x22x1 +10x1x12 +11x17x15 +29x11x30 +17x30x27 +21x22x17 +13x6x22 +22x16x12 +27x18x19 +4x13x6 +27x29x10 +3x23x10 +26x16x24 +18x26x20 +11x28x16 +21x6x15 +9x26x17 +8x15x8 +3x7x10 +2x28x8 +1x2x24 +7x8x9 +19x4x22 +11x20x9 +12x22x16 +26x8x19 +13x28x24 +4x10x16 +12x8x10 +14x24x24 +19x19x28 +29x1x15 +10x5x14 +20x19x23 +10x7x12 +1x7x13 +5x12x13 +25x21x8 +22x28x8 +7x9x4 +3x20x15 +15x27x19 +18x24x12 +16x10x16 +22x19x8 +15x4x3 +9x30x25 +1x1x6 +24x4x25 +13x18x29 +10x2x8 +21x1x17 +29x14x22 +17x29x11 +10x27x16 +25x16x15 +14x2x17 +12x27x3 +14x17x25 +24x4x1 +18x28x18 +9x14x26 +28x24x17 +1x26x12 +2x18x20 +12x19x22 +19x25x20 +5x17x27 +17x29x16 +29x19x11 +16x2x4 +23x24x1 +19x18x3 +28x14x6 +18x5x23 +9x24x12 +15x4x6 +15x7x24 +22x15x8 +22x1x22 +6x4x22 +26x1x30 +8x21x27 +7x1x11 +9x8x18 +20x27x12 +26x23x20 +26x22x30 +24x3x16 +8x24x28 +13x28x5 +4x29x23 +22x5x8 +20x22x3 +9x9x17 +28x3x30 +10x13x10 +10x25x13 +9x20x3 +1x21x25 +24x21x15 +21x5x14 +13x8x20 +29x17x3 +5x17x28 +16x12x7 +23x1x24 +4x24x29 +23x25x14 +8x27x2 +23x11x13 +13x4x5 +24x1x26 +21x1x23 +10x12x12 +21x29x25 +27x25x30 +24x23x4 +1x30x23 +29x28x14 +4x11x30 +9x25x10 +17x11x6 +14x29x30 +23x5x5 +25x18x21 +8x7x1 +27x11x3 +5x10x8 +11x1x11 +16x17x26 +15x22x19 +16x9x6 +18x13x27 +26x4x22 +1x20x21 +6x14x29 +11x7x6 +1x23x7 +12x19x13 +18x21x25 +15x17x20 +23x8x9 +15x9x26 +9x12x9 +12x13x14 +27x26x7 +11x19x22 +16x12x21 +10x30x28 +21x2x7 +12x9x18 +7x17x14 +13x17x17 +3x21x10 +30x9x15 +2x8x15 +15x12x10 +23x26x9 +29x30x10 +30x22x17 +17x26x30 +27x26x20 +17x28x17 +30x12x16 +7x23x15 +30x15x19 +13x19x10 +22x10x4 +17x23x10 +2x28x18 +27x21x28 +24x26x5 +6x23x25 +17x4x16 +14x1x13 +23x21x11 +14x15x30 +26x13x10 +30x19x25 +26x6x26 +9x16x29 +15x2x24 +13x3x20 +23x12x30 +22x23x23 +8x21x2 +18x28x5 +21x27x14 +29x28x23 +12x30x28 +17x16x3 +5x19x11 +28x22x22 +1x4x28 +10x10x14 +18x15x7 +18x11x1 +12x7x16 +10x22x24 +27x25x6 +19x29x25 +10x1x26 +26x27x30 +4x23x19 +24x19x4 +21x11x14 +4x13x27 +9x1x11 +16x20x8 +4x3x11 +1x16x12 +14x6x30 +8x1x10 +11x18x7 +29x28x30 +4x21x8 +3x21x4 +6x1x5 +26x18x3 +28x27x27 +17x3x12 +6x1x22 +23x12x28 +12x13x2 +11x2x13 +7x1x28 +27x6x25 +14x14x3 +14x11x20 +2x27x7 +22x24x23 +7x15x20 +30x6x17 +20x23x25 +18x16x27 +2x9x6 +9x18x19 +20x11x22 +11x16x19 +14x29x23 +14x9x20 +8x10x12 +18x17x6 +28x7x16 +12x19x28 +5x3x16 +1x25x10 +4x14x10 +9x6x3 +15x27x28 +13x26x14 +21x8x25 +29x10x20 +14x26x30 +25x13x28 +1x15x23 +6x20x21 +18x2x1 +22x25x16 +23x25x17 +2x14x21 +14x25x16 +12x17x6 +19x29x15 +25x9x6 +19x17x13 +24x22x5 +19x4x13 +10x18x6 +6x25x6 +23x24x20 +8x22x13 +25x10x29 +5x12x25 +20x5x11 +7x16x29 +29x24x22 +28x20x1 +10x27x10 +6x9x27 +26x15x30 +26x3x19 +20x11x3 +26x1x29 +6x23x4 +6x13x21 +9x23x25 +15x1x10 +29x12x13 +7x8x24 +29x30x27 +3x29x19 +14x16x17 +4x8x27 +26x17x8 +10x27x17 +11x28x17 +17x16x27 +1x8x22 +6x30x16 +7x30x22 +20x12x3 +18x10x2 +20x21x26 +11x1x17 +9x15x15 +19x14x30 +24x22x20 +11x26x23 +14x3x23 +1x28x29 +29x20x4 +1x4x20 +12x26x8 +14x11x14 +14x19x13 +15x13x24 +16x7x26 +11x20x11 +5x24x26 +24x25x7 +21x3x14 +24x29x20 +7x12x1 +16x17x4 +29x16x21 +28x8x17 +11x30x25 +1x26x23 +25x19x28 +30x24x5 +26x29x15 +4x25x23 +14x25x19 +29x10x7 +29x29x28 +19x13x24 +21x28x5 +8x15x24 +1x10x12 +2x26x6 +14x14x4 +10x16x27 +9x17x25 +25x8x7 +1x9x28 +10x8x17 +4x12x1 +17x26x29 +23x12x26 +2x21x22 +18x23x13 +1x14x5 +25x27x26 +4x30x30 +5x13x2 +17x9x6 +28x18x28 +7x30x2 +28x22x17 +14x15x14 +10x14x19 +6x15x22 +27x4x17 +28x21x6 +19x29x26 +6x17x17 +20x13x16 +25x4x1 +2x9x5 +30x3x1 +24x21x2 +14x19x12 +22x5x23 +14x4x21 +10x2x17 +3x14x10 +17x5x3 +22x17x13 +5x19x3 +29x22x6 +12x28x3 +9x21x25 +10x2x14 +13x26x7 +18x23x2 +9x14x17 +21x3x13 +13x23x9 +1x20x4 +11x4x1 +19x5x30 +9x9x29 +26x29x14 +1x4x10 +7x27x30 +8x3x23 +1x27x27 +7x27x27 +1x26x16 +29x16x14 +18x6x12 +24x24x24 +26x2x19 +15x17x4 +11x7x14 +14x19x10 +9x10x1 +14x17x9 +20x19x13 +25x20x8 +24x20x21 +26x30x2 +24x2x10 +28x4x13 +27x17x11 +15x3x8 +11x29x10 +26x15x16 +4x28x22 +7x5x22 +10x28x9 +6x28x13 +10x5x6 +20x12x6 +25x30x30 +17x16x14 +14x20x3 +16x10x8 +9x28x14 +16x12x12 +11x13x25 +21x16x28 +10x3x18 +5x9x20 +17x23x5 +3x13x16 +29x30x17 +2x2x8 +15x8x30 +20x1x16 +23x10x29 +4x5x4 +6x18x12 +26x10x22 +21x10x17 +26x12x29 +7x20x21 +18x9x15 +10x23x20 +20x1x27 +10x10x3 +25x12x23 +30x11x15 +16x22x3 +22x10x11 +15x10x20 +2x20x17 +20x20x1 +24x16x4 +23x27x7 +7x27x22 +24x16x8 +20x11x25 +30x28x11 +21x6x24 +15x2x9 +16x30x24 +21x27x9 +7x19x8 +24x13x28 +12x26x28 +16x21x11 +25x5x13 +23x3x17 +23x1x17 +4x17x18 +17x13x18 +25x12x19 +17x4x19 +4x21x26 +6x28x1 +23x22x15 +6x23x12 +21x17x9 +30x4x23 +2x19x21 +28x24x7 +19x24x14 +13x20x26 +19x24x29 +8x26x3 +16x12x14 +17x4x21 +8x4x20 +13x27x17 +9x21x1 +29x25x6 +7x9x26 +13x25x5 +6x9x21 +12x10x11 +30x28x21 +15x6x2 +8x18x19 +26x20x24 +26x17x14 +27x8x1 +19x19x18 +25x24x27 +14x29x15 +22x26x1 +14x17x9 +2x6x23 +29x7x5 +14x16x19 +14x21x18 +10x15x23 +21x29x14 +20x29x30 +23x11x5 diff --git a/day2/day2.readme b/day2/day2.readme new file mode 100644 index 0000000..d329683 --- /dev/null +++ b/day2/day2.readme @@ -0,0 +1,25 @@ +--- Day 2: I Was Told There Would Be No Math --- + +The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as much as they need. + +Fortunately, every present is a box (a perfect right rectangular prism), which makes calculating the required wrapping paper for each gift a little easier: find the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each present: the area of the smallest side. + +For example: + + - A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping paper plus 6 square feet of slack, for a total of 58 square feet. + - A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping paper plus 1 square foot of slack, for a total of 43 square feet. + +All numbers in the elves' list are in feet. How many total square feet of wrapping paper should they order? + +--- Part Two --- + +The elves are also running low on ribbon. Ribbon is all the same width, so they only have to worry about the length they need to order, which they would again like to be exact. + +The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face. Each present also requires a bow made out of ribbon as well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present. Don't ask how they tie the bow, though; they'll never tell. + +For example: + + - A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet. + - A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 feet. + +How many total feet of ribbon should they order? diff --git a/day3.c b/day3.c deleted file mode 100644 index 7179be6..0000000 --- a/day3.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include - -int** make2dWithOffset(int rows, int cols, int roff, int coff) { - int i; - - int** arr = (int**) malloc(rows * sizeof(int*)); - for(i = 0; i < rows ; i++) - arr[i] = (int*) malloc(cols * sizeof(int)) + coff; - - return (arr + roff); -} - -void free2dWithOffset(int** arr, int rows, int roff, int coff) { - int i; - for(i = -roff; i < rows - roff ; i++) - free(arr[i] - coff); - free(arr - roff); -} - -int main() { - int** somap = make2dWithOffset(400, 400, 200, 200); - int** rsmap = make2dWithOffset(400, 400, 200, 200); - int ch, i, j, sosum = 0, rssum = 0, odd = 1; - int soeasting = 0, sonorthing = 0, - seasting = 0, snorthing = 0, - rseasting = 0, rsnorthing = 0; - - for(i = -200; i < 200; i++) - for(j = -200; j < 200 ; j++) { - somap[i][j] = 0; - rsmap[i][j] = 0; - } - - somap[0][0] = 1; - rsmap[0][0] = 2; - - while((ch = getchar()) != EOF) { - switch(ch) { - case '<': - soeasting--; - if (odd) - seasting--; - else - rseasting--; - break; - case '>': - soeasting++; - if (odd) - seasting++; - else - rseasting++; - break; - case 'v': - sonorthing--; - if (odd) - snorthing--; - else - rsnorthing--; - break; - case '^': - sonorthing++; - if (odd) - snorthing++; - else - rsnorthing++; - } - odd = !odd; - somap[soeasting][sonorthing]++; - rsmap[seasting][snorthing]++; - rsmap[rseasting][rsnorthing]++; - } - - for(i = -200; i < 200; i++) - for(j = -200; j < 200 ; j++) { - if(somap[i][j] > 0) - sosum++; - if(rsmap[i][j] > 0) - rssum++; - } - - free2dWithOffset(somap, 400, 200, 200); - free2dWithOffset(rsmap, 400, 200, 200); - - printf("Santa only: %d\nRobosanta: %d\n", sosum, rssum); - return 0; -} diff --git a/day3.input b/day3.input deleted file mode 100644 index f7791cc..0000000 --- a/day3.input +++ /dev/null @@ -1 +0,0 @@ -v>vvv>v<<<^^^^^<<^^>v^>^>^>^>^>^<<^><<<^vvvv>^>^><^v^><^<>^^>^vvv^>^>^^<>><>^>vvv>>^vv>^<><>^^>^>><<^><><>^<^>>vvv>v>>>v<<^<><^v>^^v^^^<^v^^>>><^>^>v<>^<>>^>^^v^>>><>v^v<>>^>^<>v^>^<>^v^^^v^^>>vv<<^^><^^>^^<^>>^^^^^v^vv<>>v^v<^v^^<><^<^vv^><>><><>v>vvv^vv^^<<><<<^v^>vvv^<^>vvvv^>^>>^v^v>vv^<>><^^^>^>>v>^>v^<>v><^<^^^vv<^^<>v^v^vv<>>>>v^v<>><^^v>vv^^>v^v>v>v>>vv>^^>^v><<^<vv^^^v>v^^^>><^^>v>^^v>>v^^^<^^v>^v>><^<^<>>v<<^^vv>^^^v<^<^^vv^>>v^>><<<>^vv^<^<>v^^<<^><>>^^^<^vv<^^^>><^^v>^^v^^^^<^v<^<<<<^v^<^^<>^^>^><<>>^v><>><^<^^^>>vv>^>^^^^^v^vvv><><^<^>v>v^v^>^><><^<^><>v<><>^v^^v>^<<<>^v^>^<v^<>>^vv>v>>>^<^>>>>>v>>^v>v><>>vvv<^^><<^>^>v<^vvvv<^^^v^^^>v^v<>v<^^v>>><>v>v>>^^<^^v><<<<<^vv<^<>^>>>^v>^v>vv>^v<>v>v<^>>v>>^>^><^^v<><><^^>^^^^>vv^v^v>^v^^v^^v>><^v>>vv<>vvvv<>>^v^>^>>v^v^<<>>^v<^^vv^><>v>^>v><<<<<<<^>^^v^<<^^>>vvv^<><>><>^^v<<^^v<^^>v^>>>v^v>v^><>v<<>v>^^v><<<<><^v^v>>^<>^<<>^>v<<>><^<<<<^v>^<^v>v>vv^>v<^<<>v^v>><v>v>>v^vvv^^>>>v^<^<<^^<<<>v^<v<^^<>^>v>>v<>^>^^>>^v<<>v^^^>>>^vv<^v^>v>^><>v^^<>^^v^^vv^<^>^<<>><<^>^v>>><<<<><<^v>v^<^><^<>>v^>^^^<>>v<>>^>>v^><<>vvv><^>>v><>v>>^>v><<><<>^<>^^^vv>v^^>>^>^<^vv^>v^>^><^<^><><v<^^v^^<<<<^><^^<^><>>^v<<^<<^vv>v>>v<^<^vv>>v^v<>^>v<>^v<<>^^v>>>v^>^v^v>^^^v><^>vvv^<<<>v<>v>^>vv^<^^v^><^^^^^v<^>>vv^v^>^^<>>><^v^<v>^v>^^v<>>vv>>^v>>^<<<<^><<<><^^>>v<>^vvvv>v^^^>^^^>^<^^vv<^v^v<v^^<>^>^<^v>vvv><<^><><^^v<<><^^><>^v>^<><<^<^^<<>vv<>^^<<^>><<<>>vvv>^>v^^v^><<^>v>^>^<^<<>v<^>vv^v^v<>vv<vv<^>v^<>^vv^v^>>>v^v><^<><<>vv^>vvv^>v>>><^^vvv<^<^>>^^>^^vv>>><^v<>^v^<<>v^^^^>>^<^>^v<^^^^v>^>>v>^>^>>>v^<<^>^<<^^<>v<^v<^<>v^v>^^v^vv>vvv>v^<^>>vvvv<>>^^<>v^<><>v<^<>v<>^>v<>vv>v<^^>v>><>>^<^^<>>^>^>vvv^v>>^>^>v><><<>v<>^v<^vv^^^<>^^<<^^^v<>>v^>vvvv>^^v^>^>^<<><^^^^<<>^<>vv^<><^>^^<>v^<>>>v><>vvvvv>v>v^^>^<vv>>v<<^<>^^^v^<><>>^<<>>><>v>^>^^^^vv^^<<><^^<v>vv<<<^<v<>>^<^>^>>v>><^^<>><<<><<><^<^v<^^v<<>><<<<^>v^>v^v^<<>>v<><^<>><>>^><>v^v>v<<>v<>v^^><<>>>v<<>>>>^>v>>>>vv>v>^<^^^<>v^<^^v^vvv^>vv>^^<<>vvv<<^^<^>^>>v>v<<<<<>^^vv^>>v>^<^^v>>v>^v<><>^<^>v>v<<<^^^v>^<<<>vvv^v^^>^>>^>v>v<>^^><>>v>^>v<<<^^^v^><><^<^<>>^v>vv<^v<<^vv>v^<v>v>^v^>^v<<^v^vv>v^<<>>v<>>vvv^^vv^^v><^>v^vv<^^<<>v<><^><>^<><vv<>^vv>v><^^v<>><^v^v><><>>vv<>>>><<^>>><^^^vvv<<><>>>v<<<<<>v^^<<^vv^>vv>^<>^v^^<>^^^vv>v^^v>^v>^<>v^^^>v^^v<^>v^v^<>v>v>v<^^vv^v<^^^^vv<<><<^>>^^<v^>>^^^><^^>^v^v>^<^>>^v<>^<^>v>^>^v^<^^^<^vv<^^>>v^>^v^>>>>^v>^^<<^<^^v^<<<>>><>^<>>>v<<><<^^<^^>v^>^>v^v<><^^v>^<^v^v>>>^^<^^vv<<^><><^<>v>>>vv>><^^^v^^^v<^^v>v<>>^^<><>v>^^>>>><>v>^v>^vv^v>^>^^^><>^<<>>><<<><>^^<<v^>v>v^^^>^>^v<<>v>vv>><<^^^>>^><^>v<^<^v>><^^>v<><>^><<><>v^>v<><^^>><>^<^^v<^<><<<^^<><>>>^>v^<><^<<^vv<^v^v^v<>v^^v>v^<^>^vv^>>><<>v^vv^<>^v^><v^<><>>v^v^><>v^vvv^^^<<^<>v^v>^^><>v>>v^<>^>v>^>><<>v^v><^v>v>>><^<^^>vv<^>^<^>^^v><><^<<^^vvv^v>^>^<>>vv>v^^v^^vv<^^>><^v>v^<vvv<>>^v><<>^v<<<>^><^vv><<^^v<^vv<>^v>>>><<<<^^<^v>^<^^<^<^^>>^^v>^^^^v^^^<<>^^vv<><^<<><>^>v<>>v^^^>^v^^v^v>>>>>^v>^>^^v>><^^^v<<^^>^<^<^><^<<>v>v>^v<><^>vv^vv><^><>^><<^^>v>v>^^^<>v>^v^^>vv^vv<^^>><>^>^<>v>><>^v<v>^><^^^v^<<^v^>v^>vv>v^<>v><^v>v<>^v<>^v>^^<>vvv^>^<><^>><^<>^v<<^v^><<^<^v>^vv^v>v<^^vv<><>vv^>v<<>v>v>^^>>><<<^>^vv>>^^^>v<^vv<>v<<>>>^<^^^^>v<^^<>v>vvv^>v>v<^>^v^<>v>>vvv>^^><^vvv>><>>>^<<^>>v^^>>^><>v<^^v^<<>^<>>><^v^v>>>^vvvv^<><<>v>^v^v>v><^<<^>^^>v<^v^<^>v>^<v^<>v^<>vv^<>^>^>v^>^vv<>^^<<>>v<>^v<><><<v>v^>vv^><<<^v<><>^^v^^v^^^>^<>>>>^><>>v>>v<<>v<<<<<<<^v<<^^^v<^v<>v^^<<<^<>>v^vv^<^^<^^<<^>vv><^<^^v<<<^><^v<^><>v^v^^>>><<^<<^<>>^>>^<<<>>v>^v>><>v>>v>><>v>><^^>^^vv<^^<^>vv><<^>><<>^vvv><^v^>vvv^>>^<><^>^<<>>v^v>v<<>^>>^>v<^^<^<<>^^v^^v>v<>^<^^<v^^vvv^^v>^vv^<>v<^v^>^vv<v^<<^>^><^^<^^<^>vv^<>^<>^>^^<^v><<<^>vv^vv>v^v<>^^v^<^^^vvv^>v^<><>v>vv<^v^>>^v<^^vv>vv>^>><<<<>^><>>v<>>v>^v<^vv>^^>^<^<>v^v<^^v<^^>^^<>^^^^>^vv<^>><^>vv^>v^>^vv>^>v^^<>>^v<>>v<^>^v>vv^>^>>>vvv>vv>^><^v<<<>^^v>v^v<^^^v^^>^><<^^>^><^^^^^^^<^v<^>>vv>>^v^vv<>><>^>>>^^^^^><^<<^v<>vv^>>v<^vv<^v<>v<>^v^<<>>>>v^^>^vv<<><<>v^v<^<^>>^^><^>^><<><^<><>vv>>>>^><<^^^<^v^>^>^^>^<^><^^<^^<>><>><<<>^>^^v<>^<<>vv>^>>^>^<>>vv<^^vv<>v<>^^>^v^v^v>^^^v<<<^vv^><>^>^^vv>v^<<^><>>vv^^^^^>v>>v<<<>^<><^v<^v<^>^<>^vvv>^>v><<v>vv^<^^>v^v>^<^v^<^v<<^>^<><>^^<>>^^<^v^<^<<^>v^^>v^v^^^<^v<<^v>^>>^^^^^><<>v^><>v^^<^v<^<v^^^><^^^><<<<<>^<<^<>>v<^>><^^^<>>>>vvv>v<>>>v^v^v<^<<^>^<<>v>>^>^^><^><<^v^^<^<>v^v>vv<>>>>>>v<<>>^^>v<<<>^<<^><<^v>vv>>>><><>v^<^v><^>v>>^^^v<^>>^>>v<<^<<>vvv>>^v<>>^v><<<^v^v<>^vvv^^^<>vvv^^^>>v>^>^<><<>vv>^v^>>^<v><><<>^^><>^<<>^v<<>>v^vv<<>^^v^v^v><^>v>v<^<<^<^>vv>^v<<^>^>>v^<v^^v^^>><<<>^v>><>v<>><^v>^^v<<<<^v^vv<<<<><><^<^<^v><<^^v^<<<<<^^><^^>vvv<^><>vvv^v^>^>^^^v<<^<^^>vv^vv^><^v^<<>v<^^>^vv<<>^<<><^>v^<<^<>v><><>v<<^^><^^^v>>v>^vv>^v^^<><<<<<^>^v^<^<^^>^vv<^>v^^v^<>v<>v^v>vvv><><<><>vv^^>^^^<><^>^^^>vvv><>v<>>v^>v^^vv^>v>>>><^^>^v^v>>vv<^>><<<^>><^<^>^<^>^>>v^<^<>^<^^<>^<>>><^<^<^<<^><^^>vv<>^^>v^>>v>>>v<<^vv^<><>>>^^<^v^>>^>>><<^<>^>>^v>>><^^^<<^vv><><<>^^^<>^^^>><>>>^>vv>^<^<>>^<^^>v^>vv><><>>><><<^^v<<^vvv<><><<^v>^v<>^<^^^v^>^<^><^v>v>^v<>><^^v^^^^^<>>vvvv>>>>^<<><^v>vv>>^^><<><><^^^<^<^<<^v>^^^>>>>><v^^^<>>vv^^^v<><^>v>><<><>v<^><<>>><>v>^<>>^>v^v<<<<>^vv<<>>>>>vv<><>^<^v>vv^<>><<>^<>><^>>>><<>^^>><<<^^^^^v>>^<<>>vvvv<^v^vvv<<<^><>>>>vv^<^v>v<^<>^v>>^<^^v^>>><>^^<^v>>v<<>vvvv>^><>v^<>^<<^vv<^>>^v^>^^<<<^>>^^>^<^^<^<<v^^v^^<^v<^>>><<>vv<<^><^>vv<^>>^vv>>>^>>><^<<<>>^<<>><^<<^^^>>v^^>v<<<>v>v>v^<>>>^vvv><<^^<<><^v>>>>vv^^v^v<>v>v<<<<><<>vv<><^^^<>>v>>>>^^<><^<^v^>>^^v>^<v>^^>^v^<>>v^^<^v^^<<>^^>v^^>><<<<^<^^v>^^v>v<^>v^<>vv>>^^v>v^^>vvvvv<<>vv>vvvvvv>>v>>^^^vv^^><>v^^^^v>vv>v<^v>>>>^>^>^v>^>>><<>>^vv>>>><><<^<^><^vv^v>>>>>v>^>^^v^>v<^v^<^<v<>>^vv<<>^v^v>><><<>>v^^<<>^^<>v<<^^<^^>^^>^<^><>>v<>>^^<^>><<>>^v^>v>v<<^^<<^>v>v^^v^^<<>^v>v>v<^^>^v<><^<<v<^<<<<^^>v^v^^><<><^^^v^^>>>vvv><>vv<>>^^v^v<<^>v^^v^>vv>^<^^<^v^^<^^v<<>>vv<^>>^><><>v>>v<>^<<>>> diff --git a/day3.readme b/day3.readme deleted file mode 100644 index 66077b3..0000000 --- a/day3.readme +++ /dev/null @@ -1,27 +0,0 @@ ---- Day 3: Perfectly Spherical Houses in a Vacuum --- - -Santa is delivering presents to an infinite two-dimensional grid of houses. - -He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next. Moves are always exactly one house to the north (^), south (v), east (>), or west (<). After each move, he delivers another present to the house at his new location. - -However, the elf back at the north pole has had a little too much eggnog, and so his directions are a little off, and Santa ends up visiting some houses more than once. How many houses receive at least one present? - -For example: - - - > delivers presents to 2 houses: one at the starting location, and one to the east. - - ^>v< delivers presents to 4 houses in a square, including twice to the house at his starting/ending location. - - ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. - ---- Part Two --- - -The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, to deliver presents with him. - -Santa and Robo-Santa start at the same location (delivering two presents to the same starting house), then take turns moving based on instructions from the elf, who is eggnoggedly reading from the same script as the previous year. - -This year, how many houses receive at least one present? - -For example: - - - ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south. - - ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they started. - - ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and Robo-Santa going the other. diff --git a/day3/Makefile b/day3/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day3/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day3/day3.c b/day3/day3.c new file mode 100644 index 0000000..7179be6 --- /dev/null +++ b/day3/day3.c @@ -0,0 +1,87 @@ +#include +#include + +int** make2dWithOffset(int rows, int cols, int roff, int coff) { + int i; + + int** arr = (int**) malloc(rows * sizeof(int*)); + for(i = 0; i < rows ; i++) + arr[i] = (int*) malloc(cols * sizeof(int)) + coff; + + return (arr + roff); +} + +void free2dWithOffset(int** arr, int rows, int roff, int coff) { + int i; + for(i = -roff; i < rows - roff ; i++) + free(arr[i] - coff); + free(arr - roff); +} + +int main() { + int** somap = make2dWithOffset(400, 400, 200, 200); + int** rsmap = make2dWithOffset(400, 400, 200, 200); + int ch, i, j, sosum = 0, rssum = 0, odd = 1; + int soeasting = 0, sonorthing = 0, + seasting = 0, snorthing = 0, + rseasting = 0, rsnorthing = 0; + + for(i = -200; i < 200; i++) + for(j = -200; j < 200 ; j++) { + somap[i][j] = 0; + rsmap[i][j] = 0; + } + + somap[0][0] = 1; + rsmap[0][0] = 2; + + while((ch = getchar()) != EOF) { + switch(ch) { + case '<': + soeasting--; + if (odd) + seasting--; + else + rseasting--; + break; + case '>': + soeasting++; + if (odd) + seasting++; + else + rseasting++; + break; + case 'v': + sonorthing--; + if (odd) + snorthing--; + else + rsnorthing--; + break; + case '^': + sonorthing++; + if (odd) + snorthing++; + else + rsnorthing++; + } + odd = !odd; + somap[soeasting][sonorthing]++; + rsmap[seasting][snorthing]++; + rsmap[rseasting][rsnorthing]++; + } + + for(i = -200; i < 200; i++) + for(j = -200; j < 200 ; j++) { + if(somap[i][j] > 0) + sosum++; + if(rsmap[i][j] > 0) + rssum++; + } + + free2dWithOffset(somap, 400, 200, 200); + free2dWithOffset(rsmap, 400, 200, 200); + + printf("Santa only: %d\nRobosanta: %d\n", sosum, rssum); + return 0; +} diff --git a/day3/day3.input b/day3/day3.input new file mode 100644 index 0000000..f7791cc --- /dev/null +++ b/day3/day3.input @@ -0,0 +1 @@ +v>vvv>v<<<^^^^^<<^^>v^>^>^>^>^>^<<^><<<^vvvv>^>^><^v^><^<>^^>^vvv^>^>^^<>><>^>vvv>>^vv>^<><>^^>^>><<^><><>^<^>>vvv>v>>>v<<^<><^v>^^v^^^<^v^^>>><^>^>v<>^<>>^>^^v^>>><>v^v<>>^>^<>v^>^<>^v^^^v^^>>vv<<^^><^^>^^<^>>^^^^^v^vv<>>v^v<^v^^<><^<^vv^><>><><>v>vvv^vv^^<<><<<^v^>vvv^<^>vvvv^>^>>^v^v>vv^<>><^^^>^>>v>^>v^<>v><^<^^^vv<^^<>v^v^vv<>>>>v^v<>><^^v>vv^^>v^v>v>v>>vv>^^>^v><<^<vv^^^v>v^^^>><^^>v>^^v>>v^^^<^^v>^v>><^<^<>>v<<^^vv>^^^v<^<^^vv^>>v^>><<<>^vv^<^<>v^^<<^><>>^^^<^vv<^^^>><^^v>^^v^^^^<^v<^<<<<^v^<^^<>^^>^><<>>^v><>><^<^^^>>vv>^>^^^^^v^vvv><><^<^>v>v^v^>^><><^<^><>v<><>^v^^v>^<<<>^v^>^<v^<>>^vv>v>>>^<^>>>>>v>>^v>v><>>vvv<^^><<^>^>v<^vvvv<^^^v^^^>v^v<>v<^^v>>><>v>v>>^^<^^v><<<<<^vv<^<>^>>>^v>^v>vv>^v<>v>v<^>>v>>^>^><^^v<><><^^>^^^^>vv^v^v>^v^^v^^v>><^v>>vv<>vvvv<>>^v^>^>>v^v^<<>>^v<^^vv^><>v>^>v><<<<<<<^>^^v^<<^^>>vvv^<><>><>^^v<<^^v<^^>v^>>>v^v>v^><>v<<>v>^^v><<<<><^v^v>>^<>^<<>^>v<<>><^<<<<^v>^<^v>v>vv^>v<^<<>v^v>><v>v>>v^vvv^^>>>v^<^<<^^<<<>v^<v<^^<>^>v>>v<>^>^^>>^v<<>v^^^>>>^vv<^v^>v>^><>v^^<>^^v^^vv^<^>^<<>><<^>^v>>><<<<><<^v>v^<^><^<>>v^>^^^<>>v<>>^>>v^><<>vvv><^>>v><>v>>^>v><<><<>^<>^^^vv>v^^>>^>^<^vv^>v^>^><^<^><><v<^^v^^<<<<^><^^<^><>>^v<<^<<^vv>v>>v<^<^vv>>v^v<>^>v<>^v<<>^^v>>>v^>^v^v>^^^v><^>vvv^<<<>v<>v>^>vv^<^^v^><^^^^^v<^>>vv^v^>^^<>>><^v^<v>^v>^^v<>>vv>>^v>>^<<<<^><<<><^^>>v<>^vvvv>v^^^>^^^>^<^^vv<^v^v<v^^<>^>^<^v>vvv><<^><><^^v<<><^^><>^v>^<><<^<^^<<>vv<>^^<<^>><<<>>vvv>^>v^^v^><<^>v>^>^<^<<>v<^>vv^v^v<>vv<vv<^>v^<>^vv^v^>>>v^v><^<><<>vv^>vvv^>v>>><^^vvv<^<^>>^^>^^vv>>><^v<>^v^<<>v^^^^>>^<^>^v<^^^^v>^>>v>^>^>>>v^<<^>^<<^^<>v<^v<^<>v^v>^^v^vv>vvv>v^<^>>vvvv<>>^^<>v^<><>v<^<>v<>^>v<>vv>v<^^>v>><>>^<^^<>>^>^>vvv^v>>^>^>v><><<>v<>^v<^vv^^^<>^^<<^^^v<>>v^>vvvv>^^v^>^>^<<><^^^^<<>^<>vv^<><^>^^<>v^<>>>v><>vvvvv>v>v^^>^<vv>>v<<^<>^^^v^<><>>^<<>>><>v>^>^^^^vv^^<<><^^<v>vv<<<^<v<>>^<^>^>>v>><^^<>><<<><<><^<^v<^^v<<>><<<<^>v^>v^v^<<>>v<><^<>><>>^><>v^v>v<<>v<>v^^><<>>>v<<>>>>^>v>>>>vv>v>^<^^^<>v^<^^v^vvv^>vv>^^<<>vvv<<^^<^>^>>v>v<<<<<>^^vv^>>v>^<^^v>>v>^v<><>^<^>v>v<<<^^^v>^<<<>vvv^v^^>^>>^>v>v<>^^><>>v>^>v<<<^^^v^><><^<^<>>^v>vv<^v<<^vv>v^<v>v>^v^>^v<<^v^vv>v^<<>>v<>>vvv^^vv^^v><^>v^vv<^^<<>v<><^><>^<><vv<>^vv>v><^^v<>><^v^v><><>>vv<>>>><<^>>><^^^vvv<<><>>>v<<<<<>v^^<<^vv^>vv>^<>^v^^<>^^^vv>v^^v>^v>^<>v^^^>v^^v<^>v^v^<>v>v>v<^^vv^v<^^^^vv<<><<^>>^^<v^>>^^^><^^>^v^v>^<^>>^v<>^<^>v>^>^v^<^^^<^vv<^^>>v^>^v^>>>>^v>^^<<^<^^v^<<<>>><>^<>>>v<<><<^^<^^>v^>^>v^v<><^^v>^<^v^v>>>^^<^^vv<<^><><^<>v>>>vv>><^^^v^^^v<^^v>v<>>^^<><>v>^^>>>><>v>^v>^vv^v>^>^^^><>^<<>>><<<><>^^<<v^>v>v^^^>^>^v<<>v>vv>><<^^^>>^><^>v<^<^v>><^^>v<><>^><<><>v^>v<><^^>><>^<^^v<^<><<<^^<><>>>^>v^<><^<<^vv<^v^v^v<>v^^v>v^<^>^vv^>>><<>v^vv^<>^v^><v^<><>>v^v^><>v^vvv^^^<<^<>v^v>^^><>v>>v^<>^>v>^>><<>v^v><^v>v>>><^<^^>vv<^>^<^>^^v><><^<<^^vvv^v>^>^<>>vv>v^^v^^vv<^^>><^v>v^<vvv<>>^v><<>^v<<<>^><^vv><<^^v<^vv<>^v>>>><<<<^^<^v>^<^^<^<^^>>^^v>^^^^v^^^<<>^^vv<><^<<><>^>v<>>v^^^>^v^^v^v>>>>>^v>^>^^v>><^^^v<<^^>^<^<^><^<<>v>v>^v<><^>vv^vv><^><>^><<^^>v>v>^^^<>v>^v^^>vv^vv<^^>><>^>^<>v>><>^v<v>^><^^^v^<<^v^>v^>vv>v^<>v><^v>v<>^v<>^v>^^<>vvv^>^<><^>><^<>^v<<^v^><<^<^v>^vv^v>v<^^vv<><>vv^>v<<>v>v>^^>>><<<^>^vv>>^^^>v<^vv<>v<<>>>^<^^^^>v<^^<>v>vvv^>v>v<^>^v^<>v>>vvv>^^><^vvv>><>>>^<<^>>v^^>>^><>v<^^v^<<>^<>>><^v^v>>>^vvvv^<><<>v>^v^v>v><^<<^>^^>v<^v^<^>v>^<v^<>v^<>vv^<>^>^>v^>^vv<>^^<<>>v<>^v<><><<v>v^>vv^><<<^v<><>^^v^^v^^^>^<>>>>^><>>v>>v<<>v<<<<<<<^v<<^^^v<^v<>v^^<<<^<>>v^vv^<^^<^^<<^>vv><^<^^v<<<^><^v<^><>v^v^^>>><<^<<^<>>^>>^<<<>>v>^v>><>v>>v>><>v>><^^>^^vv<^^<^>vv><<^>><<>^vvv><^v^>vvv^>>^<><^>^<<>>v^v>v<<>^>>^>v<^^<^<<>^^v^^v>v<>^<^^<v^^vvv^^v>^vv^<>v<^v^>^vv<v^<<^>^><^^<^^<^>vv^<>^<>^>^^<^v><<<^>vv^vv>v^v<>^^v^<^^^vvv^>v^<><>v>vv<^v^>>^v<^^vv>vv>^>><<<<>^><>>v<>>v>^v<^vv>^^>^<^<>v^v<^^v<^^>^^<>^^^^>^vv<^>><^>vv^>v^>^vv>^>v^^<>>^v<>>v<^>^v>vv^>^>>>vvv>vv>^><^v<<<>^^v>v^v<^^^v^^>^><<^^>^><^^^^^^^<^v<^>>vv>>^v^vv<>><>^>>>^^^^^><^<<^v<>vv^>>v<^vv<^v<>v<>^v^<<>>>>v^^>^vv<<><<>v^v<^<^>>^^><^>^><<><^<><>vv>>>>^><<^^^<^v^>^>^^>^<^><^^<^^<>><>><<<>^>^^v<>^<<>vv>^>>^>^<>>vv<^^vv<>v<>^^>^v^v^v>^^^v<<<^vv^><>^>^^vv>v^<<^><>>vv^^^^^>v>>v<<<>^<><^v<^v<^>^<>^vvv>^>v><<v>vv^<^^>v^v>^<^v^<^v<<^>^<><>^^<>>^^<^v^<^<<^>v^^>v^v^^^<^v<<^v>^>>^^^^^><<>v^><>v^^<^v<^<v^^^><^^^><<<<<>^<<^<>>v<^>><^^^<>>>>vvv>v<>>>v^v^v<^<<^>^<<>v>>^>^^><^><<^v^^<^<>v^v>vv<>>>>>>v<<>>^^>v<<<>^<<^><<^v>vv>>>><><>v^<^v><^>v>>^^^v<^>>^>>v<<^<<>vvv>>^v<>>^v><<<^v^v<>^vvv^^^<>vvv^^^>>v>^>^<><<>vv>^v^>>^<v><><<>^^><>^<<>^v<<>>v^vv<<>^^v^v^v><^>v>v<^<<^<^>vv>^v<<^>^>>v^<v^^v^^>><<<>^v>><>v<>><^v>^^v<<<<^v^vv<<<<><><^<^<^v><<^^v^<<<<<^^><^^>vvv<^><>vvv^v^>^>^^^v<<^<^^>vv^vv^><^v^<<>v<^^>^vv<<>^<<><^>v^<<^<>v><><>v<<^^><^^^v>>v>^vv>^v^^<><<<<<^>^v^<^<^^>^vv<^>v^^v^<>v<>v^v>vvv><><<><>vv^^>^^^<><^>^^^>vvv><>v<>>v^>v^^vv^>v>>>><^^>^v^v>>vv<^>><<<^>><^<^>^<^>^>>v^<^<>^<^^<>^<>>><^<^<^<<^><^^>vv<>^^>v^>>v>>>v<<^vv^<><>>>^^<^v^>>^>>><<^<>^>>^v>>><^^^<<^vv><><<>^^^<>^^^>><>>>^>vv>^<^<>>^<^^>v^>vv><><>>><><<^^v<<^vvv<><><<^v>^v<>^<^^^v^>^<^><^v>v>^v<>><^^v^^^^^<>>vvvv>>>>^<<><^v>vv>>^^><<><><^^^<^<^<<^v>^^^>>>>><v^^^<>>vv^^^v<><^>v>><<><>v<^><<>>><>v>^<>>^>v^v<<<<>^vv<<>>>>>vv<><>^<^v>vv^<>><<>^<>><^>>>><<>^^>><<<^^^^^v>>^<<>>vvvv<^v^vvv<<<^><>>>>vv^<^v>v<^<>^v>>^<^^v^>>><>^^<^v>>v<<>vvvv>^><>v^<>^<<^vv<^>>^v^>^^<<<^>>^^>^<^^<^<<v^^v^^<^v<^>>><<>vv<<^><^>vv<^>>^vv>>>^>>><^<<<>>^<<>><^<<^^^>>v^^>v<<<>v>v>v^<>>>^vvv><<^^<<><^v>>>>vv^^v^v<>v>v<<<<><<>vv<><^^^<>>v>>>>^^<><^<^v^>>^^v>^<v>^^>^v^<>>v^^<^v^^<<>^^>v^^>><<<<^<^^v>^^v>v<^>v^<>vv>>^^v>v^^>vvvvv<<>vv>vvvvvv>>v>>^^^vv^^><>v^^^^v>vv>v<^v>>>>^>^>^v>^>>><<>>^vv>>>><><<^<^><^vv^v>>>>>v>^>^^v^>v<^v^<^<v<>>^vv<<>^v^v>><><<>>v^^<<>^^<>v<<^^<^^>^^>^<^><>>v<>>^^<^>><<>>^v^>v>v<<^^<<^>v>v^^v^^<<>^v>v>v<^^>^v<><^<<v<^<<<<^^>v^v^^><<><^^^v^^>>>vvv><>vv<>>^^v^v<<^>v^^v^>vv>^<^^<^v^^<^^v<<>>vv<^>>^><><>v>>v<>^<<>>> diff --git a/day3/day3.readme b/day3/day3.readme new file mode 100644 index 0000000..66077b3 --- /dev/null +++ b/day3/day3.readme @@ -0,0 +1,27 @@ +--- Day 3: Perfectly Spherical Houses in a Vacuum --- + +Santa is delivering presents to an infinite two-dimensional grid of houses. + +He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next. Moves are always exactly one house to the north (^), south (v), east (>), or west (<). After each move, he delivers another present to the house at his new location. + +However, the elf back at the north pole has had a little too much eggnog, and so his directions are a little off, and Santa ends up visiting some houses more than once. How many houses receive at least one present? + +For example: + + - > delivers presents to 2 houses: one at the starting location, and one to the east. + - ^>v< delivers presents to 4 houses in a square, including twice to the house at his starting/ending location. + - ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. + +--- Part Two --- + +The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, to deliver presents with him. + +Santa and Robo-Santa start at the same location (delivering two presents to the same starting house), then take turns moving based on instructions from the elf, who is eggnoggedly reading from the same script as the previous year. + +This year, how many houses receive at least one present? + +For example: + + - ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south. + - ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they started. + - ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and Robo-Santa going the other. diff --git a/day4.c b/day4.c deleted file mode 100644 index ae3fb94..0000000 --- a/day4.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include - -unsigned char* secret = "iwrupvqb"; -unsigned char* target = "000000"; -unsigned char result[MD5_DIGEST_LENGTH]; - -void hash(int i) { - char num[12]; - sprintf(num, "%d", i); - char str[22] = ""; - strcat(str, secret); - strcat(str, num); - - MD5(str, strlen(str), result); -} - -int tohex() { - int i, dg = 0; - for(i = 0; i < 4; i++) { - dg <<= 8; - dg += result[i]; - } - return dg; -} - -int check(int len) { - unsigned char str[8]; - int dg = tohex(); - sprintf(str, "%08x", dg); - return strncmp(str, target, len) == 0; -} - -int main() { - int i = 1, got5 = 0, got6 = 0; - - while(!(got5 && got6)) { - hash(i); - if(!got5 && check(5)) { - got5 = 1; - printf("Lowest number for 5-zeroes hash: %d\n", i); - } - if(!got6 && check(6)) { - got6 = 1; - printf("Lowest number for 6-zeroes hash: %d\n", i); - } - i++; - } - - return 0; -} diff --git a/day4.readme b/day4.readme deleted file mode 100644 index b629160..0000000 --- a/day4.readme +++ /dev/null @@ -1,14 +0,0 @@ ---- Day 4: The Ideal Stocking Stuffer --- - -Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys. - -To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3, ...) that produces such a hash. - -For example: - - - If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. - - If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like 000006136ef.... - ---- Part Two --- - -Now find one that starts with six zeroes. diff --git a/day4/Makefile b/day4/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day4/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day4/day4.c b/day4/day4.c new file mode 100644 index 0000000..339ea1a --- /dev/null +++ b/day4/day4.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +unsigned char secret[10]; +unsigned char target[10]; +unsigned char result[MD5_DIGEST_LENGTH]; + +void hash(int i) { + char num[12]; + sprintf(num, "%d", i); + char str[22] = ""; + strcat(str, secret); + strcat(str, num); + + MD5(str, strlen(str), result); +} + +int tohex() { + int i, dg = 0; + for(i = 0; i < 4; i++) { + dg <<= 8; + dg += result[i]; + } + return dg; +} + +int check(int len) { + unsigned char str[8]; + int dg = tohex(); + sprintf(str, "%08x", dg); + return strncmp(str, target, len) == 0; +} + +int main() { + int i = 1, got5 = 0, got6 = 0; + + scanf("%s", secret); + scanf("%s", target); + + while(!(got5 && got6)) { + hash(i); + if(!got5 && check(5)) { + got5 = 1; + printf("Lowest number for 5-zeroes hash: %d\n", i); + } + if(!got6 && check(6)) { + got6 = 1; + printf("Lowest number for 6-zeroes hash: %d\n", i); + } + i++; + } + + return 0; +} diff --git a/day4/day4.input b/day4/day4.input new file mode 100644 index 0000000..5d8d296 --- /dev/null +++ b/day4/day4.input @@ -0,0 +1,2 @@ +iwrupvqb +000000 diff --git a/day4/day4.readme b/day4/day4.readme new file mode 100644 index 0000000..b629160 --- /dev/null +++ b/day4/day4.readme @@ -0,0 +1,14 @@ +--- Day 4: The Ideal Stocking Stuffer --- + +Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys. + +To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3, ...) that produces such a hash. + +For example: + + - If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. + - If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like 000006136ef.... + +--- Part Two --- + +Now find one that starts with six zeroes. diff --git a/day4/override.mk b/day4/override.mk new file mode 100644 index 0000000..b031763 --- /dev/null +++ b/day4/override.mk @@ -0,0 +1 @@ +DAYFLAGS=-lcrypto diff --git a/day5.c b/day5.c deleted file mode 100644 index 3d737b2..0000000 --- a/day5.c +++ /dev/null @@ -1,52 +0,0 @@ -#include - -int oldmodel(char* line) { - int i; - char flags = 4, vowels = 0; - - for(i = 0; i < 16; i++) { - if( line[i] == 'a' || - line[i] == 'e' || - line[i] == 'i' || - line[i] == 'o' || - line[i] == 'u' ) vowels++; - if(i < 15) { - if(line[i] == line[i+1]) flags |= 2; - if(line[i] == 'a' && line[i+1] == 'b') flags &= 3; - if(line[i] == 'c' && line[i+1] == 'd') flags &= 3; - if(line[i] == 'p' && line[i+1] == 'q') flags &= 3; - if(line[i] == 'x' && line[i+1] == 'y') flags &= 3; - } - } - if (vowels > 2) flags |= 1; - - return (flags == 7); -} - -int newmodel(char* line) { - int i, j; - char flags = 0, vowels = 0; - - for(i = 0; i < 14; i++) { - for(j = i+2; j < 16; j++) - if(line[i] == line[j] && line[i+1] == line[j+1]) flags |= 1; - if(line[i] == line[i+2]) flags |= 2; - } - - return (flags == 3); -} - -int main() { - char line[20]; - int oldnice = 0, newnice = 0; - - while (scanf("%s", line) != EOF) { - if(oldmodel(line)) oldnice++; - if(newmodel(line)) newnice++; - } - - printf("Old model: %d\n", oldnice); - printf("New model: %d\n", newnice); - - return 0; -} diff --git a/day5.input b/day5.input deleted file mode 100644 index a9b6e77..0000000 --- a/day5.input +++ /dev/null @@ -1,1000 +0,0 @@ -sszojmmrrkwuftyv -isaljhemltsdzlum -fujcyucsrxgatisb -qiqqlmcgnhzparyg -oijbmduquhfactbc -jqzuvtggpdqcekgk -zwqadogmpjmmxijf -uilzxjythsqhwndh -gtssqejjknzkkpvw -wrggegukhhatygfi -vhtcgqzerxonhsye -tedlwzdjfppbmtdx -iuvrelxiapllaxbg -feybgiimfthtplui -qxmmcnirvkzfrjwd -vfarmltinsriqxpu -oanqfyqirkraesfq -xilodxfuxphuiiii -yukhnchvjkfwcbiq -bdaibcbzeuxqplop -ivegnnpbiyxqsion -ybahkbzpditgwdgt -dmebdomwabxgtctu -ibtvimgfaeonknoh -jsqraroxudetmfyw -dqdbcwtpintfcvuz -tiyphjunlxddenpj -fgqwjgntxagidhah -nwenhxmakxqkeehg -zdoheaxqpcnlhnen -tfetfqojqcdzlpbm -qpnxkuldeiituggg -xwttlbdwxohahwar -hjkwzadmtrkegzye -koksqrqcfwcaxeof -wulwmrptktliyxeq -gyufbedqhhyqgqzj -txpunzodohikzlmj -jloqfuejfkemcrvu -amnflshcheuddqtc -pdvcsduggcogbiia -yrioavgfmeafjpcz -uyhbtmbutozzqfvq -mwhgfwsgyuwcdzik -auqylgxhmullxpaa -lgelzivplaeoivzh -uyvcepielfcmswoa -qhirixgwkkccuzlp -zoonniyosmkeejfg -iayfetpixkedyana -ictqeyzyqswdskiy -ejsgqteafvmorwxe -lhaiqrlqqwfbrqdx -ydjyboqwhfpqfydc -dwhttezyanrnbybv -edgzkqeqkyojowvr -rmjfdwsqamjqehdq -ozminkgnkwqctrxz -bztjhxpjthchhfcd -vrtioawyxkivrpiq -dpbcsznkpkaaclyy -vpoypksymdwttpvz -hhdlruwclartkyap -bqkrcbrksbzcggbo -jerbbbnxlwfvlaiw -dwkasufidwjrjfbf -kkfxtjhbnmqbmfwf -vmnfziwqxmioukmj -rqxvcultipkecdtu -fhmfdibhtjzkiqsd -hdpjbuzzbyafqrpd -emszboysjuvwwvts -msyigmwcuybfiooq -druyksfnbluvnwoh -fvgstvynnfbvxhsx -bmzalvducnqtuune -lzwkzfzttsvpllei -olmplpvjamynfyfd -padcwfkhystsvyfb -wjhbvxkwtbfqdilb -hruaqjwphonnterf -bufjobjtvxtzjpmj -oiedrjvmlbtwyyuy -sgiemafwfztwsyju -nsoqqfudrtwszyqf -vonbxquiiwxnazyl -yvnmjxtptujwqudn -rrnybqhvrcgwvrkq -taktoxzgotzxntfu -quffzywzpxyaepxa -rfvjebfiddcfgmwv -iaeozntougqwnzoh -scdqyrhoqmljhoil -bfmqticltmfhxwld -brbuktbyqlyfpsdl -oidnyhjkeqenjlhd -kujsaiqojopvrygg -vebzobmdbzvjnjtk -uunoygzqjopwgmbg -piljqxgicjzgifso -ikgptwcjzywswqnw -pujqsixoisvhdvwi -trtuxbgigogfsbbk -mplstsqclhhdyaqk -gzcwflvmstogdpvo -tfjywbkmimyyqcjd -gijutvhruqcsiznq -ibxkhjvzzxgavkha -btnxeqvznkxjsgmq -tjgofgauxaelmjoq -sokshvyhlkxerjrv -ltogbivktqmtezta -uduwytzvqvfluyuf -msuckpthtgzhdxan -fqmcglidvhvpirzr -gwztkqpcwnutvfga -bsjfgsrntdhlpqbx -xloczbqybxmiopwt -orvevzyjliomkkgu -mzjbhmfjjvaziget -tlsdxuhwdmghdyjb -atoecyjhwmznaewi -pyxpyvvipbqibiox -ajbfmpqqobfsmesj -siknbzefjblnohgd -eqfhgewbblwdfkmc -opylbscrotckkrbk -lbwxbofgjkzdxkle -ceixfjstaptdomvm -hnkrqxifjmmjktie -aqykzeuzvvetoygd -fouahjimfcisxima -prkzhutbqsyrhjzx -qqwliakathnsbzne -sayhgqtlcqqidqhj -ygduolbysehdudra -zricvxhdzznuxuce -ucvzakslykpgsixd -udirhgcttmyspgsb -yuwzppjzfsjhhdzi -gtqergjiuwookwre -xvxexbjyjkxovvwf -mlpaqhnnkqxrmwmm -ezuqbrjozwuqafhb -mcarusdthcbsonoq -weeguqeheeiigrue -pngtfugozxofaqxv -copphvbjcmfspenv -jiyahihykjjkdaya -gdqnmesvptuyrfwp -vbdscfywqmfxbohh -crtrfuxyjypzubrg -seihvevtxywxhflp -fvvpmgttnapklwou -qmqaqsajmqwhetpk -zetxvrgjmblxvakr -kpvwblrizaabmnhz -mwpvvzaaicntrkcp -clqyjiegtdsswqfm -ymrcnqgcpldgfwtm -nzyqpdenetncgnwq -cmkzevgacnmdkqro -kzfdsnamjqbeirhi -kpxrvgvvxapqlued -rzskbnfobevzrtqu -vjoahbfwtydugzap -ykbbldkoijlvicbl -mfdmroiztsgjlasb -quoigfyxwtwprmdr -ekxjqafwudgwfqjm -obtvyjkiycxfcdpb -lhoihfnbuqelthof -eydwzitgxryktddt -rxsihfybacnpoyny -bsncccxlplqgygtw -rvmlaudsifnzhcqh -huxwsyjyebckcsnn -gtuqzyihwhqvjtes -zreeyomtngvztveq -nwddzjingsarhkxb -nuqxqtctpoldrlsh -wkvnrwqgjooovhpf -kwgueyiyffudtbyg -tpkzapnjxefqnmew -ludwccvkihagvxal -lfdtzhfadvabghna -njqmlsnrkcfhtvbb -cajzbqleghhnlgap -vmitdcozzvqvzatp -eelzefwqwjiywbcz -uyztcuptfqvymjpi -aorhnrpkjqqtgnfo -lfrxfdrduoeqmwwp -vszpjvbctblplinh -zexhadgpqfifcqrz -ueirfnshekpemqua -qfremlntihbwabtb -nwznunammfexltjc -zkyieokaaogjehwt -vlrxgkpclzeslqkq -xrqrwfsuacywczhs -olghlnfjdiwgdbqc -difnlxnedpqcsrdf -dgpuhiisybjpidsj -vlwmwrikmitmoxbt -sazpcmcnviynoktm -pratafauetiknhln -ilgteekhzwlsfwcn -ywvwhrwhkaubvkbl -qlaxivzwxyhvrxcf -hbtlwjdriizqvjfb -nrmsononytuwslsa -mpxqgdthpoipyhjc -mcdiwmiqeidwcglk -vfbaeavmjjemfrmo -qzcbzmisnynzibrc -shzmpgxhehhcejhb -wirtjadsqzydtyxd -qjlrnjfokkqvnpue -dxawdvjntlbxtuqc -wttfmnrievfestog -eamjfvsjhvzzaobg -pbvfcwzjgxahlrag -omvmjkqqnobvnzkn -lcwmeibxhhlxnkzv -uiaeroqfbvlazegs -twniyldyuonfyzqw -wgjkmsbwgfotdabi -hnomamxoxvrzvtew -ycrcfavikkrxxfgw -isieyodknagzhaxy -mgzdqwikzullzyco -mumezgtxjrrejtrs -nwmwjcgrqiwgfqel -wjgxmebfmyjnxyyp -durpspyljdykvzxf -zuslbrpooyetgafh -kuzrhcjwbdouhyme -wyxuvbciodscbvfm -kbnpvuqwmxwfqtqe -zddzercqogdpxmft -sigrdchxtgavzzjh -lznjolnorbuddgcs -ycnqabxlcajagwbt -bnaudeaexahdgxsj -rlnykxvoctfwanms -jngyetkoplrstfzt -tdpxknwacksotdub -yutqgssfoptvizgr -lzmqnxeqjfnsxmsa -iqpgfsfmukovsdgu -qywreehbidowtjyz -iozamtgusdctvnkw -ielmujhtmynlwcfd -hzxnhtbnmmejlkyf -ftbslbzmiqkzebtd -bcwdqgiiizmohack -dqhfkzeddjzbdlxu -mxopokqffisxosci -vciatxhtuechbylk -khtkhcvelidjdena -blatarwzfqcapkdt -elamngegnczctcck -xeicefdbwrxhuxuf -sawvdhjoeahlgcdr -kmdcimzsfkdfpnir -axjayzqlosrduajb -mfhzreuzzumvoggr -iqlbkbhrkptquldb -xcvztvlshiefuhgb -pkvwyqmyoazocrio -ajsxkdnerbmhyxaj -tudibgsbnpnizvsi -cxuiydkgdccrqvkh -cyztpjesdzmbcpot -nnazphxpanegwitx -uphymczbmjalmsct -yyxiwnlrogyzwqmg -gmqwnahjvvdyhnfa -utolskxpuoheugyl -mseszdhyzoyavepd -ycqknvbuvcjfgmlc -sknrxhxbfpvpeorn -zqxqjetooqcodwml -sesylkpvbndrdhsy -fryuxvjnsvnjrxlw -mfxusewqurscujnu -mbitdjjtgzchvkfv -ozwlyxtaalxofovd -wdqcduaykxbunpie -rlnhykxiraileysk -wgoqfrygttlamobg -kflxzgxvcblkpsbz -tmkisflhativzhde -owsdrfgkaamogjzd -gaupjkvkzavhfnes -wknkurddcknbdleg -lltviwincmbtduap -qwzvspgbcksyzzmb -ydzzkumecryfjgnk -jzvmwgjutxoysaam -icrwpyhxllbardkr -jdopyntshmvltrve -afgkigxcuvmdbqou -mfzzudntmvuyhjzt -duxhgtwafcgrpihc -tsnhrkvponudumeb -sqtvnbeiigdzbjgv -eczmkqwvnsrracuo -mhehsgqwiczaiaxv -kaudmfvifovrimpd -lupikgivechdbwfr -mwaaysrndiutuiqx -aacuiiwgaannunmm -tjqjbftaqitukwzp -lrcqyskykbjpaekn -lirrvofbcqpjzxmr -jurorvzpplyelfml -qonbllojmloykjqe -sllkzqujfnbauuqp -auexjwsvphvikali -usuelbssqmbrkxyc -wyuokkfjexikptvv -wmfedauwjgbrgytl -sfwvtlzzebxzmuvw -rdhqxuechjsjcvaf -kpavhqkukugocsxu -ovnjtumxowbxduts -zgerpjufauptxgat -pevvnzjfwhjxdoxq -pmmfwxajgfziszcs -difmeqvaghuitjhs -icpwjbzcmlcterwm -ngqpvhajttxuegyh -mosjlqswdngwqsmi -frlvgpxrjolgodlu -eazwgrpcxjgoszeg -bbtsthgkjrpkiiyk -tjonoglufuvsvabe -xhkbcrofytmbzrtk -kqftfzdmpbxjynps -kmeqpocbnikdtfyv -qjjymgqxhnjwxxhp -dmgicrhgbngdtmjt -zdxrhdhbdutlawnc -afvoekuhdboxghvx -hiipezngkqcnihty -bbmqgheidenweeov -suprgwxgxwfsgjnx -adeagikyamgqphrj -zzifqinoeqaorjxg -adhgppljizpaxzld -lvxyieypvvuqjiyc -nljoakatwwwoovzn -fcrkfxclcacshhmx -ownnxqtdhqbgthch -lmfylrcdmdkgpwnj -hlwjfbvlswbzpbjr -mkofhdtljdetcyvp -synyxhifbetzarpo -agnggugngadrcxoc -uhttadmdmhidpyjw -ohfwjfhunalbubpr -pzkkkkwrlvxiuysn -kmidbxmyzkjrwjhu -egtitdydwjxmajnw -civoeoiuwtwgbqqs -dfptsguzfinqoslk -tdfvkreormspprer -zvnvbrmthatzztwi -ffkyddccrrfikjde -hrrmraevdnztiwff -qaeygykcpbtjwjbr -purwhitkmrtybslh -qzziznlswjaussel -dfcxkvdpqccdqqxj -tuotforulrrytgyn -gmtgfofgucjywkev -wkyoxudvdkbgpwhd -qbvktvfvipftztnn -otckgmojziezmojb -inxhvzbtgkjxflay -qvxapbiatuudseno -krpvqosbesnjntut -oqeukkgjsfuqkjbb -prcjnyymnqwqksiz -vuortvjxgckresko -orqlyobvkuwgathr -qnpyxlnazyfuijox -zwlblfkoklqmqzkw -hmwurwtpwnrcsanl -jzvxohuakopuzgpf -sfcpnxrviphhvxmx -qtwdeadudtqhbely -dbmkmloasqphnlgj -olylnjtkxgrubmtk -nxsdbqjuvwrrdbpq -wbabpirnpcsmpipw -hjnkyiuxpqrlvims -enzpntcjnxdpuqch -vvvqhlstzcizyimn -triozhqndbttglhv -fukvgteitwaagpzx -uhcvukfbmrvskpen -tizcyupztftzxdmt -vtkpnbpdzsaluczz -wodfoyhoekidxttm -otqocljrmwfqbxzu -linfbsnfvixlwykn -vxsluutrwskslnye -zbshygtwugixjvsi -zdcqwxvwytmzhvoo -wrseozkkcyctrmei -fblgtvogvkpqzxiy -opueqnuyngegbtnf -qxbovietpacqqxok -zacrdrrkohfygddn -gbnnvjqmkdupwzpq -qgrgmsxeotozvcak -hnppukzvzfmlokid -dzbheurndscrrtcl -wbgdkadtszebbrcw -fdmzppzphhpzyuiz -bukomunhrjrypohj -ohodhelegxootqbj -rsplgzarlrknqjyh -punjjwpsxnhpzgvu -djdfahypfjvpvibm -mlgrqsmhaozatsvy -xwktrgyuhqiquxgn -wvfaoolwtkbrisvf -plttjdmguxjwmeqr -zlvvbwvlhauyjykw -cigwkbyjhmepikej -masmylenrusgtyxs -hviqzufwyetyznze -nzqfuhrooswxxhus -pdbdetaqcrqzzwxf -oehmvziiqwkzhzib -icgpyrukiokmytoy -ooixfvwtiafnwkce -rvnmgqggpjopkihs -wywualssrmaqigqk -pdbvflnwfswsrirl -jeaezptokkccpbuj -mbdwjntysntsaaby -ldlgcawkzcwuxzpz -lwktbgrzswbsweht -ecspepmzarzmgpjm -qmfyvulkmkxjncai -izftypvwngiukrns -zgmnyjfeqffbooww -nyrkhggnprhedows -yykzzrjmlevgffah -mavaemfxhlfejfki -cmegmfjbkvpncqwf -zxidlodrezztcrij -fseasudpgvgnysjv -fupcimjupywzpqzp -iqhgokavirrcvyys -wjmkcareucnmfhui -nftflsqnkgjaexhq -mgklahzlcbapntgw -kfbmeavfxtppnrxn -nuhyvhknlufdynvn -nviogjxbluwrcoec -tyozixxxaqiuvoys -kgwlvmvgtsvxojpr -moeektyhyonfdhrb -kahvevmmfsmiiqex -xcywnqzcdqtvhiwd -fnievhiyltbvtvem -jlmndqufirwgtdxd -muypbfttoeelsnbs -rypxzbnujitfwkou -ubmmjbznskildeoj -ofnmizdeicrmkjxp -rekvectjbmdnfcib -yohrojuvdexbctdh -gwfnfdeibynzjmhz -jfznhfcqdwlpjull -scrinzycfhwkmmso -mskutzossrwoqqsi -rygoebkzgyzushhr -jpjqiycflqkexemx -arbufysjqmgaapnl -dbjerflevtgweeoj -snybnnjlmwjvhois -fszuzplntraprmbj -mkvaatolvuggikvg -zpuzuqygoxesnuyc -wnpxvmxvllxalulm -eivuuafkvudeouwy -rvzckdyixetfuehr -qgmnicdoqhveahyx -miawwngyymshjmpj -pvckyoncpqeqkbmx -llninfenrfjqxurv -kzbjnlgsqjfuzqtp -rveqcmxomvpjcwte -bzotkawzbopkosnx -ktqvpiribpypaymu -wvlzkivbukhnvram -uohntlcoguvjqqdo -ajlsiksjrcnzepkt -xsqatbldqcykwusd -ihbivgzrwpmowkop -vfayesfojmibkjpb -uaqbnijtrhvqxjtb -hhovshsfmvkvymba -jerwmyxrfeyvxcgg -hncafjwrlvdcupma -qyvigggxfylbbrzt -hiiixcyohmvnkpgk -mmitpwopgxuftdfu -iaxderqpceboixoa -zodfmjhuzhnsqfcb -sthtcbadrclrazsi -bkkkkcwegvypbrio -wmpcofuvzemunlhj -gqwebiifvqoeynro -juupusqdsvxcpsgv -rbhdfhthxelolyse -kjimpwnjfrqlqhhz -rcuigrjzarzpjgfq -htxcejfyzhydinks -sxucpdxhvqjxxjwf -omsznfcimbcwaxal -gufmtdlhgrsvcosb -bssshaqujtmluerz -uukotwjkstgwijtr -kbqkneobbrdogrxk -ljqopjcjmelgrakz -rwtfnvnzryujwkfb -dedjjbrndqnilbeh -nzinsxnpptzagwlb -lwqanydfirhnhkxy -hrjuzfumbvfccxno -okismsadkbseumnp -sfkmiaiwlktxqvwa -hauwpjjwowbunbjj -nowkofejwvutcnui -bqzzppwoslaeixro -urpfgufwbtzenkpj -xgeszvuqwxeykhef -yxoldvkyuikwqyeq -onbbhxrnmohzskgg -qcikuxakrqeugpoa -lnudcqbtyzhlpers -nxduvwfrgzaailgl -xniuwvxufzxjjrwz -ljwithcqmgvntjdj -awkftfagrfzywkhs -uedtpzxyubeveuek -bhcqdwidbjkqqhzl -iyneqjdmlhowwzxx -kvshzltcrrururty -zgfpiwajegwezupo -tkrvyanujjwmyyri -ercsefuihcmoaiep -ienjrxpmetinvbos -jnwfutjbgenlipzq -bgohjmrptfuamzbz -rtsyamajrhxbcncw -tfjdssnmztvbnscs -bgaychdlmchngqlp -kfjljiobynhwfkjo -owtdxzcpqleftbvn -ltjtimxwstvzwzjj -wbrvjjjajuombokf -zblpbpuaqbkvsxye -gwgdtbpnlhyqspdi -abipqjihjqfofmkx -nlqymnuvjpvvgova -avngotmhodpoufzn -qmdyivtzitnrjuae -xfwjmqtqdljuerxi -csuellnlcyqaaamq -slqyrcurcyuoxquo -dcjmxyzbzpohzprl -uqfnmjwniyqgsowb -rbmxpqoblyxdocqc -ebjclrdbqjhladem -ainnfhxnsgwqnmyo -eyytjjwhvodtzquf -iabjgmbbhilrcyyp -pqfnehkivuelyccc -xgjbyhfgmtseiimt -jwxyqhdbjiqqqeyy -gxsbrncqkmvaryln -vhjisxjkinaejytk -seexagcdmaedpcvh -lvudfgrcpjxzdpvd -fxtegyrqjzhmqean -dnoiseraqcoossmc -nwrhmwwbykvwmgep -udmzskejvizmtlce -hbzvqhvudfdlegaa -cghmlfqejbxewskv -bntcmjqfwomtbwsb -qezhowyopjdyhzng -todzsocdkgfxanbz -zgjkssrjlwxuhwbk -eibzljqsieriyrzr -wamxvzqyycrxotjp -epzvfkispwqynadu -dwlpfhtrafrxlyie -qhgzujhgdruowoug -girstvkahaemmxvh -baitcrqmxhazyhbl -xyanqcchbhkajdmc -gfvjmmcgfhvgnfdq -tdfdbslwncbnkzyz -jojuselkpmnnbcbb -hatdslkgxtqpmavj -dvelfeddvgjcyxkj -gnsofhkfepgwltse -mdngnobasfpewlno -qssnbcyjgmkyuoga -glvcmmjytmprqwvn -gwrixumjbcdffsdl -lozravlzvfqtsuiq -sicaflbqdxbmdlch -inwfjkyyqbwpmqlq -cuvszfotxywuzhzi -igfxyoaacoarlvay -ucjfhgdmnjvgvuni -rvvkzjsytqgiposh -jduinhjjntrmqroz -yparkxbgsfnueyll -lyeqqeisxzfsqzuj -woncskbibjnumydm -lltucklragtjmxtl -ubiyvmyhlesfxotj -uecjseeicldqrqww -xxlxkbcthufnjbnm -lhqijovvhlffpxga -fzdgqpzijitlogjz -efzzjqvwphomxdpd -jvgzvuyzobeazssc -hejfycgxywfjgbfw -yhjjmvkqfbnbliks -sffvfyywtlntsdsz -dwmxqudvxqdenrur -asnukgppdemxrzaz -nwqfnumblwvdpphx -kqsmkkspqvxzuket -cpnraovljzqiquaz -qrzgrdlyyzbyykhg -opoahcbiydyhsmqe -hjknnfdauidjeydr -hczdjjlygoezadow -rtflowzqycimllfv -sfsrgrerzlnychhq -bpahuvlblcolpjmj -albgnjkgmcrlaicl -pijyqdhfxpaxzdex -eeymiddvcwkpbpux -rqwkqoabywgggnln -vckbollyhgbgmgwh -ylzlgvnuvpynybkm -hpmbxtpfosbsjixt -ocebeihnhvkhjfqz -tvctyxoujdgwayze -efvhwxtuhapqxjen -rusksgefyidldmpo -nkmtjvddfmhirmzz -whvtsuadwofzmvrt -iiwjqvsdxudhdzzk -gucirgxaxgcassyo -rmhfasfzexeykwmr -hynlxcvsbgosjbis -huregszrcaocueen -pifezpoolrnbdqtv -unatnixzvdbqeyox -xtawlpduxgacchfe -bdvdbflqfphndduf -xtdsnjnmzccfptyt -nkhsdkhqtzqbphhg -aqcubmfkczlaxiyb -moziflxpsfubucmv -srdgnnjtfehiimqx -pwfalehdfyykrohf -sysxssmvewyfjrve -brsemdzosgqvvlxe -bimbjoshuvflkiat -hkgjasmljkpkwwku -sbnmwjvodygobpqc -bbbqycejueruihhd -corawswvlvneipyc -gcyhknmwsczcxedh -kppakbffdhntmcqp -ynulzwkfaemkcefp -pyroowjekeurlbii -iwksighrswdcnmxf -glokrdmugreygnsg -xkmvvumnfzckryop -aesviofpufygschi -csloawlirnegsssq -fkqdqqmlzuxbkzbc -uzlhzcfenxdfjdzp -poaaidrktteusvyf -zrlyfzmjzfvivcfr -qwjulskbniitgqtx -gjeszjksbfsuejki -vczdejdbfixbduaq -knjdrjthitjxluth -jweydeginrnicirl -bottrfgccqhyycsl -eiquffofoadmbuhk -lbqfutmzoksscswf -xfmdvnvfcnzjprba -uvugkjbkhlaoxmyx -wadlgtpczgvcaqqv -inzrszbtossflsxk -dbzbtashaartczrj -qbjiqpccefcfkvod -hluujmokjywotvzy -thwlliksfztcmwzh -arahybspdaqdexrq -nuojrmsgyipdvwyx -hnajdwjwmzattvst -sulcgaxezkprjbgu -rjowuugwdpkjtypw -oeugzwuhnrgiaqga -wvxnyymwftfoswij -pqxklzkjpcqscvde -tuymjzknntekglqj -odteewktugcwlhln -exsptotlfecmgehc -eeswfcijtvzgrqel -vjhrkiwmunuiwqau -zhlixepkeijoemne -pavfsmwesuvebzdd -jzovbklnngfdmyws -nbajyohtzfeoiixz -ciozmhrsjzrwxvhz -gwucrxieqbaqfjuv -uayrxrltnohexawc -flmrbhwsfbcquffm -gjyabmngkitawlxc -rwwtggvaygfbovhg -xquiegaisynictjq -oudzwuhexrwwdbyy -lengxmguyrwhrebb -uklxpglldbgqsjls -dbmvlfeyguydfsxq -zspdwdqcrmtmdtsc -mqfnzwbfqlauvrgc -amcrkzptgacywvhv -ndxmskrwrqysrndf -mwjyhsufeqhwisju -srlrukoaenyevykt -tnpjtpwawrxbikct -geczalxmgxejulcv -tvkcbqdhmuwcxqci -tiovluvwezwwgaox -zrjhtbgajkjqzmfo -vcrywduwsklepirs -lofequdigsszuioy -wxsdzomkjqymlzat -iabaczqtrfbmypuy -ibdlmudbajikcncr -rqcvkzsbwmavdwnv -ypxoyjelhllhbeog -fdnszbkezyjbttbg -uxnhrldastpdjkdz -xfrjbehtxnlyzcka -omjyfhbibqwgcpbv -eguucnoxaoprszmp -xfpypldgcmcllyzz -aypnmgqjxjqceelv -mgzharymejlafvgf -tzowgwsubbaigdok -ilsehjqpcjwmylxc -pfmouwntfhfnmrwk -csgokybgdqwnduwp -eaxwvxvvwbrovypz -nmluqvobbbmdiwwb -lnkminvfjjzqbmio -mjiiqzycqdhfietz -towlrzriicyraevq -obiloewdvbrsfwjo -lmeooaajlthsfltw -ichygipzpykkesrw -gfysloxmqdsfskvt -saqzntehjldvwtsx -pqddoemaufpfcaew -mjrxvbvwcreaybwe -ngfbrwfqnxqosoai -nesyewxreiqvhald -kqhqdlquywotcyfy -liliptyoqujensfi -nsahsaxvaepzneqq -zaickulfjajhctye -gxjzahtgbgbabtht -koxbuopaqhlsyhrp -jhzejdjidqqtjnwe -dekrkdvprfqpcqki -linwlombdqtdeyop -dvckqqbnigdcmwmx -yaxygbjpzkvnnebv -rlzkdkgaagmcpxah -cfzuyxivtknirqvt -obivkajhsjnrxxhn -lmjhayymgpseuynn -bbjyewkwadaipyju -lmzyhwomfypoftuu -gtzhqlgltvatxack -jfflcfaqqkrrltgq -txoummmnzfrlrmcg -ohemsbfuqqpucups -imsfvowcbieotlok -tcnsnccdszxfcyde -qkcdtkwuaquajazz -arcfnhmdjezdbqku -srnocgyqrlcvlhkb -mppbzvfmcdirbyfw -xiuarktilpldwgwd -ypufwmhrvzqmexpc -itpdnsfkwgrdujmj -cmpxnodtsswkyxkr -wayyxtjklfrmvbfp -mfaxphcnjczhbbwy -sjxhgwdnqcofbdra -pnxmujuylqccjvjm -ivamtjbvairwjqwl -deijtmzgpfxrclss -bzkqcaqagsynlaer -tycefobvxcvwaulz -ctbhnywezxkdsswf -urrxxebxrthtjvib -fpfelcigwqwdjucv -ngfcyyqpqulwcphb -rltkzsiipkpzlgpw -qfdsymzwhqqdkykc -balrhhxipoqzmihj -rnwalxgigswxomga -ghqnxeogckshphgr -lyyaentdizaumnla -exriodwfzosbeoib -speswfggibijfejk -yxmxgfhvmshqszrq -hcqhngvahzgawjga -qmhlsrfpesmeksur -eviafjejygakodla -kvcfeiqhynqadbzv -fusvyhowslfzqttg -girqmvwmcvntrwau -yuavizroykfkdekz -jmcwohvmzvowrhxf -kzimlcpavapynfue -wjudcdtrewfabppq -yqpteuxqgbmqfgxh -xdgiszbuhdognniu -jsguxfwhpftlcjoh -whakkvspssgjzxre -ggvnvjurlyhhijgm -krvbhjybnpemeptr -pqedgfojyjybfbzr -jzhcrsgmnkwwtpdo -yyscxoxwofslncmp -gzjhnxytmyntzths -iteigbnqbtpvqumi -zjevfzusnjukqpfw -xippcyhkfuounxqk -mcnhrcfonfdgpkyh -pinkcyuhjkexbmzj -lotxrswlxbxlxufs -fmqajrtoabpckbnu -wfkwsgmcffdgaqxg -qfrsiwnohoyfbidr -czfqbsbmiuyusaqs -ieknnjeecucghpoo -cevdgqnugupvmsge -gjkajcyjnxdrtuvr -udzhrargnujxiclq -zqqrhhmjwermjssg -ggdivtmgoqajydzz -wnpfsgtxowkjiivl -afbhqawjbotxnqpd -xjpkifkhfjeqifdn -oyfggzsstfhvticp -kercaetahymeawxy -khphblhcgmbupmzt -iggoqtqpvaebtiol -ofknifysuasshoya -qxuewroccsbogrbv -apsbnbkiopopytgu -zyahfroovfjlythh -bxhjwfgeuxlviydq -uvbhdtvaypasaswa -qamcjzrmesqgqdiz -hjnjyzrxntiycyel -wkcrwqwniczwdxgq -hibxlvkqakusswkx -mzjyuenepwdgrkty -tvywsoqslfsulses -jqwcwuuisrclircv -xanwaoebfrzhurct -ykriratovsvxxasf -qyebvtqqxbjuuwuo -telrvlwvriylnder -acksrrptgnhkeiaa -yemwfjhiqlzsvdxf -banrornfkcymmkcc -ytbhxvaeiigjpcgm -crepyazgxquposkn -xlqwdrytzwnxzwzv -xtrbfbwopxscftps -kwbytzukgseeyjla -qtfdvavvjogybxjg -ytbmvmrcxwfkgvzw -nbscbdskdeocnfzr -sqquwjbdxsxhcseg -ewqxhigqcgszfsuw -cvkyfcyfmubzwsee -dcoawetekigxgygd -ohgqnqhfimyuqhvi -otisopzzpvnhctte -bauieohjejamzien -ewnnopzkujbvhwce -aeyqlskpaehagdiv -pncudvivwnnqspxy -ytugesilgveokxcg -zoidxeelqdjesxpr -ducjccsuaygfchzj -smhgllqqqcjfubfc -nlbyyywergronmir -prdawpbjhrzsbsvj -nmgzhnjhlpcplmui -eflaogtjghdjmxxz -qolvpngucbkprrdc -ixywxcienveltgho -mwnpqtocagenkxut -iskrfbwxonkguywx -ouhtbvcaczqzmpua -srewprgddfgmdbao -dyufrltacelchlvu -czmzcbrkecixuwzz -dtbeojcztzauofuk -prrgoehpqhngfgmw -baolzvfrrevxsyke -zqadgxshwiarkzwh -vsackherluvurqqj -surbpxdulvcvgjbd -wqxytarcxzgxhvtx -vbcubqvejcfsgrac -zqnjfeapshjowzja -hekvbhtainkvbynx -knnugxoktxpvoxnh -knoaalcefpgtvlwm -qoakaunowmsuvkus -ypkvlzcduzlezqcb -ujhcagawtyepyogh -wsilcrxncnffaxjf -gbbycjuscquaycrk -aduojapeaqwivnly -ceafyxrakviagcjy -nntajnghicgnrlst -vdodpeherjmmvbje -wyyhrnegblwvdobn -xlfurpghkpbzhhif -xyppnjiljvirmqjo -kglzqahipnddanpi -omjateouxikwxowr -ocifnoopfglmndcx -emudcukfbadyijev -ooktviixetfddfmh -wtvrhloyjewdeycg -cgjncqykgutfjhvb -nkwvpswppeffmwad -hqbcmfhzkxmnrivg -mdskbvzguxvieilr -anjcvqpavhdloaqh -erksespdevjylenq -fadxwbmisazyegup -iyuiffjmcaahowhj -ygkdezmynmltodbv -fytneukxqkjattvh -woerxfadbfrvdcnz -iwsljvkyfastccoa -movylhjranlorofe -drdmicdaiwukemep -knfgtsmuhfcvvshg -ibstpbevqmdlhajn -tstwsswswrxlzrqs -estyydmzothggudf -jezogwvymvikszwa -izmqcwdyggibliet -nzpxbegurwnwrnca -kzkojelnvkwfublh -xqcssgozuxfqtiwi -tcdoigumjrgvczfv -ikcjyubjmylkwlwq -kqfivwystpqzvhan -bzukgvyoqewniivj -iduapzclhhyfladn -fbpyzxdfmkrtfaeg -yzsmlbnftftgwadz diff --git a/day5.readme b/day5.readme deleted file mode 100644 index 611dc87..0000000 --- a/day5.readme +++ /dev/null @@ -1,37 +0,0 @@ ---- Day 5: Doesn't He Have Intern-Elves For This? --- - -Santa needs help figuring out which strings in his text file are naughty or nice. - -A nice string is one with all of the following properties: - - - It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou. - - It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd). - - It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements. - -For example: - - - ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double letter (...dd...), and none of the disallowed substrings. - - aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap. - - jchzalrnumimnmhp is naughty because it has no double letter. - - haegwjzuvuyypxyu is naughty because it contains the string xy. - - dvszwmarrgswjxmb is naughty because it contains only one vowel. - -How many strings are nice? - ---- Part Two --- - -Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. - -Now, a nice string is one with all of the following properties: - - - It contains a pair of any two letters that appears at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). - - It contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa. - -For example: - - - qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz). - - xxyxx is nice because it has a pair that appears twice and a letter that repeats with one between, even though the letters used by each rule overlap. - - uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them. - - ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice. - -How many strings are nice under these new rules? diff --git a/day5/Makefile b/day5/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day5/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day5/day5.c b/day5/day5.c new file mode 100644 index 0000000..3d737b2 --- /dev/null +++ b/day5/day5.c @@ -0,0 +1,52 @@ +#include + +int oldmodel(char* line) { + int i; + char flags = 4, vowels = 0; + + for(i = 0; i < 16; i++) { + if( line[i] == 'a' || + line[i] == 'e' || + line[i] == 'i' || + line[i] == 'o' || + line[i] == 'u' ) vowels++; + if(i < 15) { + if(line[i] == line[i+1]) flags |= 2; + if(line[i] == 'a' && line[i+1] == 'b') flags &= 3; + if(line[i] == 'c' && line[i+1] == 'd') flags &= 3; + if(line[i] == 'p' && line[i+1] == 'q') flags &= 3; + if(line[i] == 'x' && line[i+1] == 'y') flags &= 3; + } + } + if (vowels > 2) flags |= 1; + + return (flags == 7); +} + +int newmodel(char* line) { + int i, j; + char flags = 0, vowels = 0; + + for(i = 0; i < 14; i++) { + for(j = i+2; j < 16; j++) + if(line[i] == line[j] && line[i+1] == line[j+1]) flags |= 1; + if(line[i] == line[i+2]) flags |= 2; + } + + return (flags == 3); +} + +int main() { + char line[20]; + int oldnice = 0, newnice = 0; + + while (scanf("%s", line) != EOF) { + if(oldmodel(line)) oldnice++; + if(newmodel(line)) newnice++; + } + + printf("Old model: %d\n", oldnice); + printf("New model: %d\n", newnice); + + return 0; +} diff --git a/day5/day5.input b/day5/day5.input new file mode 100644 index 0000000..a9b6e77 --- /dev/null +++ b/day5/day5.input @@ -0,0 +1,1000 @@ +sszojmmrrkwuftyv +isaljhemltsdzlum +fujcyucsrxgatisb +qiqqlmcgnhzparyg +oijbmduquhfactbc +jqzuvtggpdqcekgk +zwqadogmpjmmxijf +uilzxjythsqhwndh +gtssqejjknzkkpvw +wrggegukhhatygfi +vhtcgqzerxonhsye +tedlwzdjfppbmtdx +iuvrelxiapllaxbg +feybgiimfthtplui +qxmmcnirvkzfrjwd +vfarmltinsriqxpu +oanqfyqirkraesfq +xilodxfuxphuiiii +yukhnchvjkfwcbiq +bdaibcbzeuxqplop +ivegnnpbiyxqsion +ybahkbzpditgwdgt +dmebdomwabxgtctu +ibtvimgfaeonknoh +jsqraroxudetmfyw +dqdbcwtpintfcvuz +tiyphjunlxddenpj +fgqwjgntxagidhah +nwenhxmakxqkeehg +zdoheaxqpcnlhnen +tfetfqojqcdzlpbm +qpnxkuldeiituggg +xwttlbdwxohahwar +hjkwzadmtrkegzye +koksqrqcfwcaxeof +wulwmrptktliyxeq +gyufbedqhhyqgqzj +txpunzodohikzlmj +jloqfuejfkemcrvu +amnflshcheuddqtc +pdvcsduggcogbiia +yrioavgfmeafjpcz +uyhbtmbutozzqfvq +mwhgfwsgyuwcdzik +auqylgxhmullxpaa +lgelzivplaeoivzh +uyvcepielfcmswoa +qhirixgwkkccuzlp +zoonniyosmkeejfg +iayfetpixkedyana +ictqeyzyqswdskiy +ejsgqteafvmorwxe +lhaiqrlqqwfbrqdx +ydjyboqwhfpqfydc +dwhttezyanrnbybv +edgzkqeqkyojowvr +rmjfdwsqamjqehdq +ozminkgnkwqctrxz +bztjhxpjthchhfcd +vrtioawyxkivrpiq +dpbcsznkpkaaclyy +vpoypksymdwttpvz +hhdlruwclartkyap +bqkrcbrksbzcggbo +jerbbbnxlwfvlaiw +dwkasufidwjrjfbf +kkfxtjhbnmqbmfwf +vmnfziwqxmioukmj +rqxvcultipkecdtu +fhmfdibhtjzkiqsd +hdpjbuzzbyafqrpd +emszboysjuvwwvts +msyigmwcuybfiooq +druyksfnbluvnwoh +fvgstvynnfbvxhsx +bmzalvducnqtuune +lzwkzfzttsvpllei +olmplpvjamynfyfd +padcwfkhystsvyfb +wjhbvxkwtbfqdilb +hruaqjwphonnterf +bufjobjtvxtzjpmj +oiedrjvmlbtwyyuy +sgiemafwfztwsyju +nsoqqfudrtwszyqf +vonbxquiiwxnazyl +yvnmjxtptujwqudn +rrnybqhvrcgwvrkq +taktoxzgotzxntfu +quffzywzpxyaepxa +rfvjebfiddcfgmwv +iaeozntougqwnzoh +scdqyrhoqmljhoil +bfmqticltmfhxwld +brbuktbyqlyfpsdl +oidnyhjkeqenjlhd +kujsaiqojopvrygg +vebzobmdbzvjnjtk +uunoygzqjopwgmbg +piljqxgicjzgifso +ikgptwcjzywswqnw +pujqsixoisvhdvwi +trtuxbgigogfsbbk +mplstsqclhhdyaqk +gzcwflvmstogdpvo +tfjywbkmimyyqcjd +gijutvhruqcsiznq +ibxkhjvzzxgavkha +btnxeqvznkxjsgmq +tjgofgauxaelmjoq +sokshvyhlkxerjrv +ltogbivktqmtezta +uduwytzvqvfluyuf +msuckpthtgzhdxan +fqmcglidvhvpirzr +gwztkqpcwnutvfga +bsjfgsrntdhlpqbx +xloczbqybxmiopwt +orvevzyjliomkkgu +mzjbhmfjjvaziget +tlsdxuhwdmghdyjb +atoecyjhwmznaewi +pyxpyvvipbqibiox +ajbfmpqqobfsmesj +siknbzefjblnohgd +eqfhgewbblwdfkmc +opylbscrotckkrbk +lbwxbofgjkzdxkle +ceixfjstaptdomvm +hnkrqxifjmmjktie +aqykzeuzvvetoygd +fouahjimfcisxima +prkzhutbqsyrhjzx +qqwliakathnsbzne +sayhgqtlcqqidqhj +ygduolbysehdudra +zricvxhdzznuxuce +ucvzakslykpgsixd +udirhgcttmyspgsb +yuwzppjzfsjhhdzi +gtqergjiuwookwre +xvxexbjyjkxovvwf +mlpaqhnnkqxrmwmm +ezuqbrjozwuqafhb +mcarusdthcbsonoq +weeguqeheeiigrue +pngtfugozxofaqxv +copphvbjcmfspenv +jiyahihykjjkdaya +gdqnmesvptuyrfwp +vbdscfywqmfxbohh +crtrfuxyjypzubrg +seihvevtxywxhflp +fvvpmgttnapklwou +qmqaqsajmqwhetpk +zetxvrgjmblxvakr +kpvwblrizaabmnhz +mwpvvzaaicntrkcp +clqyjiegtdsswqfm +ymrcnqgcpldgfwtm +nzyqpdenetncgnwq +cmkzevgacnmdkqro +kzfdsnamjqbeirhi +kpxrvgvvxapqlued +rzskbnfobevzrtqu +vjoahbfwtydugzap +ykbbldkoijlvicbl +mfdmroiztsgjlasb +quoigfyxwtwprmdr +ekxjqafwudgwfqjm +obtvyjkiycxfcdpb +lhoihfnbuqelthof +eydwzitgxryktddt +rxsihfybacnpoyny +bsncccxlplqgygtw +rvmlaudsifnzhcqh +huxwsyjyebckcsnn +gtuqzyihwhqvjtes +zreeyomtngvztveq +nwddzjingsarhkxb +nuqxqtctpoldrlsh +wkvnrwqgjooovhpf +kwgueyiyffudtbyg +tpkzapnjxefqnmew +ludwccvkihagvxal +lfdtzhfadvabghna +njqmlsnrkcfhtvbb +cajzbqleghhnlgap +vmitdcozzvqvzatp +eelzefwqwjiywbcz +uyztcuptfqvymjpi +aorhnrpkjqqtgnfo +lfrxfdrduoeqmwwp +vszpjvbctblplinh +zexhadgpqfifcqrz +ueirfnshekpemqua +qfremlntihbwabtb +nwznunammfexltjc +zkyieokaaogjehwt +vlrxgkpclzeslqkq +xrqrwfsuacywczhs +olghlnfjdiwgdbqc +difnlxnedpqcsrdf +dgpuhiisybjpidsj +vlwmwrikmitmoxbt +sazpcmcnviynoktm +pratafauetiknhln +ilgteekhzwlsfwcn +ywvwhrwhkaubvkbl +qlaxivzwxyhvrxcf +hbtlwjdriizqvjfb +nrmsononytuwslsa +mpxqgdthpoipyhjc +mcdiwmiqeidwcglk +vfbaeavmjjemfrmo +qzcbzmisnynzibrc +shzmpgxhehhcejhb +wirtjadsqzydtyxd +qjlrnjfokkqvnpue +dxawdvjntlbxtuqc +wttfmnrievfestog +eamjfvsjhvzzaobg +pbvfcwzjgxahlrag +omvmjkqqnobvnzkn +lcwmeibxhhlxnkzv +uiaeroqfbvlazegs +twniyldyuonfyzqw +wgjkmsbwgfotdabi +hnomamxoxvrzvtew +ycrcfavikkrxxfgw +isieyodknagzhaxy +mgzdqwikzullzyco +mumezgtxjrrejtrs +nwmwjcgrqiwgfqel +wjgxmebfmyjnxyyp +durpspyljdykvzxf +zuslbrpooyetgafh +kuzrhcjwbdouhyme +wyxuvbciodscbvfm +kbnpvuqwmxwfqtqe +zddzercqogdpxmft +sigrdchxtgavzzjh +lznjolnorbuddgcs +ycnqabxlcajagwbt +bnaudeaexahdgxsj +rlnykxvoctfwanms +jngyetkoplrstfzt +tdpxknwacksotdub +yutqgssfoptvizgr +lzmqnxeqjfnsxmsa +iqpgfsfmukovsdgu +qywreehbidowtjyz +iozamtgusdctvnkw +ielmujhtmynlwcfd +hzxnhtbnmmejlkyf +ftbslbzmiqkzebtd +bcwdqgiiizmohack +dqhfkzeddjzbdlxu +mxopokqffisxosci +vciatxhtuechbylk +khtkhcvelidjdena +blatarwzfqcapkdt +elamngegnczctcck +xeicefdbwrxhuxuf +sawvdhjoeahlgcdr +kmdcimzsfkdfpnir +axjayzqlosrduajb +mfhzreuzzumvoggr +iqlbkbhrkptquldb +xcvztvlshiefuhgb +pkvwyqmyoazocrio +ajsxkdnerbmhyxaj +tudibgsbnpnizvsi +cxuiydkgdccrqvkh +cyztpjesdzmbcpot +nnazphxpanegwitx +uphymczbmjalmsct +yyxiwnlrogyzwqmg +gmqwnahjvvdyhnfa +utolskxpuoheugyl +mseszdhyzoyavepd +ycqknvbuvcjfgmlc +sknrxhxbfpvpeorn +zqxqjetooqcodwml +sesylkpvbndrdhsy +fryuxvjnsvnjrxlw +mfxusewqurscujnu +mbitdjjtgzchvkfv +ozwlyxtaalxofovd +wdqcduaykxbunpie +rlnhykxiraileysk +wgoqfrygttlamobg +kflxzgxvcblkpsbz +tmkisflhativzhde +owsdrfgkaamogjzd +gaupjkvkzavhfnes +wknkurddcknbdleg +lltviwincmbtduap +qwzvspgbcksyzzmb +ydzzkumecryfjgnk +jzvmwgjutxoysaam +icrwpyhxllbardkr +jdopyntshmvltrve +afgkigxcuvmdbqou +mfzzudntmvuyhjzt +duxhgtwafcgrpihc +tsnhrkvponudumeb +sqtvnbeiigdzbjgv +eczmkqwvnsrracuo +mhehsgqwiczaiaxv +kaudmfvifovrimpd +lupikgivechdbwfr +mwaaysrndiutuiqx +aacuiiwgaannunmm +tjqjbftaqitukwzp +lrcqyskykbjpaekn +lirrvofbcqpjzxmr +jurorvzpplyelfml +qonbllojmloykjqe +sllkzqujfnbauuqp +auexjwsvphvikali +usuelbssqmbrkxyc +wyuokkfjexikptvv +wmfedauwjgbrgytl +sfwvtlzzebxzmuvw +rdhqxuechjsjcvaf +kpavhqkukugocsxu +ovnjtumxowbxduts +zgerpjufauptxgat +pevvnzjfwhjxdoxq +pmmfwxajgfziszcs +difmeqvaghuitjhs +icpwjbzcmlcterwm +ngqpvhajttxuegyh +mosjlqswdngwqsmi +frlvgpxrjolgodlu +eazwgrpcxjgoszeg +bbtsthgkjrpkiiyk +tjonoglufuvsvabe +xhkbcrofytmbzrtk +kqftfzdmpbxjynps +kmeqpocbnikdtfyv +qjjymgqxhnjwxxhp +dmgicrhgbngdtmjt +zdxrhdhbdutlawnc +afvoekuhdboxghvx +hiipezngkqcnihty +bbmqgheidenweeov +suprgwxgxwfsgjnx +adeagikyamgqphrj +zzifqinoeqaorjxg +adhgppljizpaxzld +lvxyieypvvuqjiyc +nljoakatwwwoovzn +fcrkfxclcacshhmx +ownnxqtdhqbgthch +lmfylrcdmdkgpwnj +hlwjfbvlswbzpbjr +mkofhdtljdetcyvp +synyxhifbetzarpo +agnggugngadrcxoc +uhttadmdmhidpyjw +ohfwjfhunalbubpr +pzkkkkwrlvxiuysn +kmidbxmyzkjrwjhu +egtitdydwjxmajnw +civoeoiuwtwgbqqs +dfptsguzfinqoslk +tdfvkreormspprer +zvnvbrmthatzztwi +ffkyddccrrfikjde +hrrmraevdnztiwff +qaeygykcpbtjwjbr +purwhitkmrtybslh +qzziznlswjaussel +dfcxkvdpqccdqqxj +tuotforulrrytgyn +gmtgfofgucjywkev +wkyoxudvdkbgpwhd +qbvktvfvipftztnn +otckgmojziezmojb +inxhvzbtgkjxflay +qvxapbiatuudseno +krpvqosbesnjntut +oqeukkgjsfuqkjbb +prcjnyymnqwqksiz +vuortvjxgckresko +orqlyobvkuwgathr +qnpyxlnazyfuijox +zwlblfkoklqmqzkw +hmwurwtpwnrcsanl +jzvxohuakopuzgpf +sfcpnxrviphhvxmx +qtwdeadudtqhbely +dbmkmloasqphnlgj +olylnjtkxgrubmtk +nxsdbqjuvwrrdbpq +wbabpirnpcsmpipw +hjnkyiuxpqrlvims +enzpntcjnxdpuqch +vvvqhlstzcizyimn +triozhqndbttglhv +fukvgteitwaagpzx +uhcvukfbmrvskpen +tizcyupztftzxdmt +vtkpnbpdzsaluczz +wodfoyhoekidxttm +otqocljrmwfqbxzu +linfbsnfvixlwykn +vxsluutrwskslnye +zbshygtwugixjvsi +zdcqwxvwytmzhvoo +wrseozkkcyctrmei +fblgtvogvkpqzxiy +opueqnuyngegbtnf +qxbovietpacqqxok +zacrdrrkohfygddn +gbnnvjqmkdupwzpq +qgrgmsxeotozvcak +hnppukzvzfmlokid +dzbheurndscrrtcl +wbgdkadtszebbrcw +fdmzppzphhpzyuiz +bukomunhrjrypohj +ohodhelegxootqbj +rsplgzarlrknqjyh +punjjwpsxnhpzgvu +djdfahypfjvpvibm +mlgrqsmhaozatsvy +xwktrgyuhqiquxgn +wvfaoolwtkbrisvf +plttjdmguxjwmeqr +zlvvbwvlhauyjykw +cigwkbyjhmepikej +masmylenrusgtyxs +hviqzufwyetyznze +nzqfuhrooswxxhus +pdbdetaqcrqzzwxf +oehmvziiqwkzhzib +icgpyrukiokmytoy +ooixfvwtiafnwkce +rvnmgqggpjopkihs +wywualssrmaqigqk +pdbvflnwfswsrirl +jeaezptokkccpbuj +mbdwjntysntsaaby +ldlgcawkzcwuxzpz +lwktbgrzswbsweht +ecspepmzarzmgpjm +qmfyvulkmkxjncai +izftypvwngiukrns +zgmnyjfeqffbooww +nyrkhggnprhedows +yykzzrjmlevgffah +mavaemfxhlfejfki +cmegmfjbkvpncqwf +zxidlodrezztcrij +fseasudpgvgnysjv +fupcimjupywzpqzp +iqhgokavirrcvyys +wjmkcareucnmfhui +nftflsqnkgjaexhq +mgklahzlcbapntgw +kfbmeavfxtppnrxn +nuhyvhknlufdynvn +nviogjxbluwrcoec +tyozixxxaqiuvoys +kgwlvmvgtsvxojpr +moeektyhyonfdhrb +kahvevmmfsmiiqex +xcywnqzcdqtvhiwd +fnievhiyltbvtvem +jlmndqufirwgtdxd +muypbfttoeelsnbs +rypxzbnujitfwkou +ubmmjbznskildeoj +ofnmizdeicrmkjxp +rekvectjbmdnfcib +yohrojuvdexbctdh +gwfnfdeibynzjmhz +jfznhfcqdwlpjull +scrinzycfhwkmmso +mskutzossrwoqqsi +rygoebkzgyzushhr +jpjqiycflqkexemx +arbufysjqmgaapnl +dbjerflevtgweeoj +snybnnjlmwjvhois +fszuzplntraprmbj +mkvaatolvuggikvg +zpuzuqygoxesnuyc +wnpxvmxvllxalulm +eivuuafkvudeouwy +rvzckdyixetfuehr +qgmnicdoqhveahyx +miawwngyymshjmpj +pvckyoncpqeqkbmx +llninfenrfjqxurv +kzbjnlgsqjfuzqtp +rveqcmxomvpjcwte +bzotkawzbopkosnx +ktqvpiribpypaymu +wvlzkivbukhnvram +uohntlcoguvjqqdo +ajlsiksjrcnzepkt +xsqatbldqcykwusd +ihbivgzrwpmowkop +vfayesfojmibkjpb +uaqbnijtrhvqxjtb +hhovshsfmvkvymba +jerwmyxrfeyvxcgg +hncafjwrlvdcupma +qyvigggxfylbbrzt +hiiixcyohmvnkpgk +mmitpwopgxuftdfu +iaxderqpceboixoa +zodfmjhuzhnsqfcb +sthtcbadrclrazsi +bkkkkcwegvypbrio +wmpcofuvzemunlhj +gqwebiifvqoeynro +juupusqdsvxcpsgv +rbhdfhthxelolyse +kjimpwnjfrqlqhhz +rcuigrjzarzpjgfq +htxcejfyzhydinks +sxucpdxhvqjxxjwf +omsznfcimbcwaxal +gufmtdlhgrsvcosb +bssshaqujtmluerz +uukotwjkstgwijtr +kbqkneobbrdogrxk +ljqopjcjmelgrakz +rwtfnvnzryujwkfb +dedjjbrndqnilbeh +nzinsxnpptzagwlb +lwqanydfirhnhkxy +hrjuzfumbvfccxno +okismsadkbseumnp +sfkmiaiwlktxqvwa +hauwpjjwowbunbjj +nowkofejwvutcnui +bqzzppwoslaeixro +urpfgufwbtzenkpj +xgeszvuqwxeykhef +yxoldvkyuikwqyeq +onbbhxrnmohzskgg +qcikuxakrqeugpoa +lnudcqbtyzhlpers +nxduvwfrgzaailgl +xniuwvxufzxjjrwz +ljwithcqmgvntjdj +awkftfagrfzywkhs +uedtpzxyubeveuek +bhcqdwidbjkqqhzl +iyneqjdmlhowwzxx +kvshzltcrrururty +zgfpiwajegwezupo +tkrvyanujjwmyyri +ercsefuihcmoaiep +ienjrxpmetinvbos +jnwfutjbgenlipzq +bgohjmrptfuamzbz +rtsyamajrhxbcncw +tfjdssnmztvbnscs +bgaychdlmchngqlp +kfjljiobynhwfkjo +owtdxzcpqleftbvn +ltjtimxwstvzwzjj +wbrvjjjajuombokf +zblpbpuaqbkvsxye +gwgdtbpnlhyqspdi +abipqjihjqfofmkx +nlqymnuvjpvvgova +avngotmhodpoufzn +qmdyivtzitnrjuae +xfwjmqtqdljuerxi +csuellnlcyqaaamq +slqyrcurcyuoxquo +dcjmxyzbzpohzprl +uqfnmjwniyqgsowb +rbmxpqoblyxdocqc +ebjclrdbqjhladem +ainnfhxnsgwqnmyo +eyytjjwhvodtzquf +iabjgmbbhilrcyyp +pqfnehkivuelyccc +xgjbyhfgmtseiimt +jwxyqhdbjiqqqeyy +gxsbrncqkmvaryln +vhjisxjkinaejytk +seexagcdmaedpcvh +lvudfgrcpjxzdpvd +fxtegyrqjzhmqean +dnoiseraqcoossmc +nwrhmwwbykvwmgep +udmzskejvizmtlce +hbzvqhvudfdlegaa +cghmlfqejbxewskv +bntcmjqfwomtbwsb +qezhowyopjdyhzng +todzsocdkgfxanbz +zgjkssrjlwxuhwbk +eibzljqsieriyrzr +wamxvzqyycrxotjp +epzvfkispwqynadu +dwlpfhtrafrxlyie +qhgzujhgdruowoug +girstvkahaemmxvh +baitcrqmxhazyhbl +xyanqcchbhkajdmc +gfvjmmcgfhvgnfdq +tdfdbslwncbnkzyz +jojuselkpmnnbcbb +hatdslkgxtqpmavj +dvelfeddvgjcyxkj +gnsofhkfepgwltse +mdngnobasfpewlno +qssnbcyjgmkyuoga +glvcmmjytmprqwvn +gwrixumjbcdffsdl +lozravlzvfqtsuiq +sicaflbqdxbmdlch +inwfjkyyqbwpmqlq +cuvszfotxywuzhzi +igfxyoaacoarlvay +ucjfhgdmnjvgvuni +rvvkzjsytqgiposh +jduinhjjntrmqroz +yparkxbgsfnueyll +lyeqqeisxzfsqzuj +woncskbibjnumydm +lltucklragtjmxtl +ubiyvmyhlesfxotj +uecjseeicldqrqww +xxlxkbcthufnjbnm +lhqijovvhlffpxga +fzdgqpzijitlogjz +efzzjqvwphomxdpd +jvgzvuyzobeazssc +hejfycgxywfjgbfw +yhjjmvkqfbnbliks +sffvfyywtlntsdsz +dwmxqudvxqdenrur +asnukgppdemxrzaz +nwqfnumblwvdpphx +kqsmkkspqvxzuket +cpnraovljzqiquaz +qrzgrdlyyzbyykhg +opoahcbiydyhsmqe +hjknnfdauidjeydr +hczdjjlygoezadow +rtflowzqycimllfv +sfsrgrerzlnychhq +bpahuvlblcolpjmj +albgnjkgmcrlaicl +pijyqdhfxpaxzdex +eeymiddvcwkpbpux +rqwkqoabywgggnln +vckbollyhgbgmgwh +ylzlgvnuvpynybkm +hpmbxtpfosbsjixt +ocebeihnhvkhjfqz +tvctyxoujdgwayze +efvhwxtuhapqxjen +rusksgefyidldmpo +nkmtjvddfmhirmzz +whvtsuadwofzmvrt +iiwjqvsdxudhdzzk +gucirgxaxgcassyo +rmhfasfzexeykwmr +hynlxcvsbgosjbis +huregszrcaocueen +pifezpoolrnbdqtv +unatnixzvdbqeyox +xtawlpduxgacchfe +bdvdbflqfphndduf +xtdsnjnmzccfptyt +nkhsdkhqtzqbphhg +aqcubmfkczlaxiyb +moziflxpsfubucmv +srdgnnjtfehiimqx +pwfalehdfyykrohf +sysxssmvewyfjrve +brsemdzosgqvvlxe +bimbjoshuvflkiat +hkgjasmljkpkwwku +sbnmwjvodygobpqc +bbbqycejueruihhd +corawswvlvneipyc +gcyhknmwsczcxedh +kppakbffdhntmcqp +ynulzwkfaemkcefp +pyroowjekeurlbii +iwksighrswdcnmxf +glokrdmugreygnsg +xkmvvumnfzckryop +aesviofpufygschi +csloawlirnegsssq +fkqdqqmlzuxbkzbc +uzlhzcfenxdfjdzp +poaaidrktteusvyf +zrlyfzmjzfvivcfr +qwjulskbniitgqtx +gjeszjksbfsuejki +vczdejdbfixbduaq +knjdrjthitjxluth +jweydeginrnicirl +bottrfgccqhyycsl +eiquffofoadmbuhk +lbqfutmzoksscswf +xfmdvnvfcnzjprba +uvugkjbkhlaoxmyx +wadlgtpczgvcaqqv +inzrszbtossflsxk +dbzbtashaartczrj +qbjiqpccefcfkvod +hluujmokjywotvzy +thwlliksfztcmwzh +arahybspdaqdexrq +nuojrmsgyipdvwyx +hnajdwjwmzattvst +sulcgaxezkprjbgu +rjowuugwdpkjtypw +oeugzwuhnrgiaqga +wvxnyymwftfoswij +pqxklzkjpcqscvde +tuymjzknntekglqj +odteewktugcwlhln +exsptotlfecmgehc +eeswfcijtvzgrqel +vjhrkiwmunuiwqau +zhlixepkeijoemne +pavfsmwesuvebzdd +jzovbklnngfdmyws +nbajyohtzfeoiixz +ciozmhrsjzrwxvhz +gwucrxieqbaqfjuv +uayrxrltnohexawc +flmrbhwsfbcquffm +gjyabmngkitawlxc +rwwtggvaygfbovhg +xquiegaisynictjq +oudzwuhexrwwdbyy +lengxmguyrwhrebb +uklxpglldbgqsjls +dbmvlfeyguydfsxq +zspdwdqcrmtmdtsc +mqfnzwbfqlauvrgc +amcrkzptgacywvhv +ndxmskrwrqysrndf +mwjyhsufeqhwisju +srlrukoaenyevykt +tnpjtpwawrxbikct +geczalxmgxejulcv +tvkcbqdhmuwcxqci +tiovluvwezwwgaox +zrjhtbgajkjqzmfo +vcrywduwsklepirs +lofequdigsszuioy +wxsdzomkjqymlzat +iabaczqtrfbmypuy +ibdlmudbajikcncr +rqcvkzsbwmavdwnv +ypxoyjelhllhbeog +fdnszbkezyjbttbg +uxnhrldastpdjkdz +xfrjbehtxnlyzcka +omjyfhbibqwgcpbv +eguucnoxaoprszmp +xfpypldgcmcllyzz +aypnmgqjxjqceelv +mgzharymejlafvgf +tzowgwsubbaigdok +ilsehjqpcjwmylxc +pfmouwntfhfnmrwk +csgokybgdqwnduwp +eaxwvxvvwbrovypz +nmluqvobbbmdiwwb +lnkminvfjjzqbmio +mjiiqzycqdhfietz +towlrzriicyraevq +obiloewdvbrsfwjo +lmeooaajlthsfltw +ichygipzpykkesrw +gfysloxmqdsfskvt +saqzntehjldvwtsx +pqddoemaufpfcaew +mjrxvbvwcreaybwe +ngfbrwfqnxqosoai +nesyewxreiqvhald +kqhqdlquywotcyfy +liliptyoqujensfi +nsahsaxvaepzneqq +zaickulfjajhctye +gxjzahtgbgbabtht +koxbuopaqhlsyhrp +jhzejdjidqqtjnwe +dekrkdvprfqpcqki +linwlombdqtdeyop +dvckqqbnigdcmwmx +yaxygbjpzkvnnebv +rlzkdkgaagmcpxah +cfzuyxivtknirqvt +obivkajhsjnrxxhn +lmjhayymgpseuynn +bbjyewkwadaipyju +lmzyhwomfypoftuu +gtzhqlgltvatxack +jfflcfaqqkrrltgq +txoummmnzfrlrmcg +ohemsbfuqqpucups +imsfvowcbieotlok +tcnsnccdszxfcyde +qkcdtkwuaquajazz +arcfnhmdjezdbqku +srnocgyqrlcvlhkb +mppbzvfmcdirbyfw +xiuarktilpldwgwd +ypufwmhrvzqmexpc +itpdnsfkwgrdujmj +cmpxnodtsswkyxkr +wayyxtjklfrmvbfp +mfaxphcnjczhbbwy +sjxhgwdnqcofbdra +pnxmujuylqccjvjm +ivamtjbvairwjqwl +deijtmzgpfxrclss +bzkqcaqagsynlaer +tycefobvxcvwaulz +ctbhnywezxkdsswf +urrxxebxrthtjvib +fpfelcigwqwdjucv +ngfcyyqpqulwcphb +rltkzsiipkpzlgpw +qfdsymzwhqqdkykc +balrhhxipoqzmihj +rnwalxgigswxomga +ghqnxeogckshphgr +lyyaentdizaumnla +exriodwfzosbeoib +speswfggibijfejk +yxmxgfhvmshqszrq +hcqhngvahzgawjga +qmhlsrfpesmeksur +eviafjejygakodla +kvcfeiqhynqadbzv +fusvyhowslfzqttg +girqmvwmcvntrwau +yuavizroykfkdekz +jmcwohvmzvowrhxf +kzimlcpavapynfue +wjudcdtrewfabppq +yqpteuxqgbmqfgxh +xdgiszbuhdognniu +jsguxfwhpftlcjoh +whakkvspssgjzxre +ggvnvjurlyhhijgm +krvbhjybnpemeptr +pqedgfojyjybfbzr +jzhcrsgmnkwwtpdo +yyscxoxwofslncmp +gzjhnxytmyntzths +iteigbnqbtpvqumi +zjevfzusnjukqpfw +xippcyhkfuounxqk +mcnhrcfonfdgpkyh +pinkcyuhjkexbmzj +lotxrswlxbxlxufs +fmqajrtoabpckbnu +wfkwsgmcffdgaqxg +qfrsiwnohoyfbidr +czfqbsbmiuyusaqs +ieknnjeecucghpoo +cevdgqnugupvmsge +gjkajcyjnxdrtuvr +udzhrargnujxiclq +zqqrhhmjwermjssg +ggdivtmgoqajydzz +wnpfsgtxowkjiivl +afbhqawjbotxnqpd +xjpkifkhfjeqifdn +oyfggzsstfhvticp +kercaetahymeawxy +khphblhcgmbupmzt +iggoqtqpvaebtiol +ofknifysuasshoya +qxuewroccsbogrbv +apsbnbkiopopytgu +zyahfroovfjlythh +bxhjwfgeuxlviydq +uvbhdtvaypasaswa +qamcjzrmesqgqdiz +hjnjyzrxntiycyel +wkcrwqwniczwdxgq +hibxlvkqakusswkx +mzjyuenepwdgrkty +tvywsoqslfsulses +jqwcwuuisrclircv +xanwaoebfrzhurct +ykriratovsvxxasf +qyebvtqqxbjuuwuo +telrvlwvriylnder +acksrrptgnhkeiaa +yemwfjhiqlzsvdxf +banrornfkcymmkcc +ytbhxvaeiigjpcgm +crepyazgxquposkn +xlqwdrytzwnxzwzv +xtrbfbwopxscftps +kwbytzukgseeyjla +qtfdvavvjogybxjg +ytbmvmrcxwfkgvzw +nbscbdskdeocnfzr +sqquwjbdxsxhcseg +ewqxhigqcgszfsuw +cvkyfcyfmubzwsee +dcoawetekigxgygd +ohgqnqhfimyuqhvi +otisopzzpvnhctte +bauieohjejamzien +ewnnopzkujbvhwce +aeyqlskpaehagdiv +pncudvivwnnqspxy +ytugesilgveokxcg +zoidxeelqdjesxpr +ducjccsuaygfchzj +smhgllqqqcjfubfc +nlbyyywergronmir +prdawpbjhrzsbsvj +nmgzhnjhlpcplmui +eflaogtjghdjmxxz +qolvpngucbkprrdc +ixywxcienveltgho +mwnpqtocagenkxut +iskrfbwxonkguywx +ouhtbvcaczqzmpua +srewprgddfgmdbao +dyufrltacelchlvu +czmzcbrkecixuwzz +dtbeojcztzauofuk +prrgoehpqhngfgmw +baolzvfrrevxsyke +zqadgxshwiarkzwh +vsackherluvurqqj +surbpxdulvcvgjbd +wqxytarcxzgxhvtx +vbcubqvejcfsgrac +zqnjfeapshjowzja +hekvbhtainkvbynx +knnugxoktxpvoxnh +knoaalcefpgtvlwm +qoakaunowmsuvkus +ypkvlzcduzlezqcb +ujhcagawtyepyogh +wsilcrxncnffaxjf +gbbycjuscquaycrk +aduojapeaqwivnly +ceafyxrakviagcjy +nntajnghicgnrlst +vdodpeherjmmvbje +wyyhrnegblwvdobn +xlfurpghkpbzhhif +xyppnjiljvirmqjo +kglzqahipnddanpi +omjateouxikwxowr +ocifnoopfglmndcx +emudcukfbadyijev +ooktviixetfddfmh +wtvrhloyjewdeycg +cgjncqykgutfjhvb +nkwvpswppeffmwad +hqbcmfhzkxmnrivg +mdskbvzguxvieilr +anjcvqpavhdloaqh +erksespdevjylenq +fadxwbmisazyegup +iyuiffjmcaahowhj +ygkdezmynmltodbv +fytneukxqkjattvh +woerxfadbfrvdcnz +iwsljvkyfastccoa +movylhjranlorofe +drdmicdaiwukemep +knfgtsmuhfcvvshg +ibstpbevqmdlhajn +tstwsswswrxlzrqs +estyydmzothggudf +jezogwvymvikszwa +izmqcwdyggibliet +nzpxbegurwnwrnca +kzkojelnvkwfublh +xqcssgozuxfqtiwi +tcdoigumjrgvczfv +ikcjyubjmylkwlwq +kqfivwystpqzvhan +bzukgvyoqewniivj +iduapzclhhyfladn +fbpyzxdfmkrtfaeg +yzsmlbnftftgwadz diff --git a/day5/day5.readme b/day5/day5.readme new file mode 100644 index 0000000..611dc87 --- /dev/null +++ b/day5/day5.readme @@ -0,0 +1,37 @@ +--- Day 5: Doesn't He Have Intern-Elves For This? --- + +Santa needs help figuring out which strings in his text file are naughty or nice. + +A nice string is one with all of the following properties: + + - It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou. + - It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd). + - It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements. + +For example: + + - ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double letter (...dd...), and none of the disallowed substrings. + - aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap. + - jchzalrnumimnmhp is naughty because it has no double letter. + - haegwjzuvuyypxyu is naughty because it contains the string xy. + - dvszwmarrgswjxmb is naughty because it contains only one vowel. + +How many strings are nice? + +--- Part Two --- + +Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. + +Now, a nice string is one with all of the following properties: + + - It contains a pair of any two letters that appears at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). + - It contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa. + +For example: + + - qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz). + - xxyxx is nice because it has a pair that appears twice and a letter that repeats with one between, even though the letters used by each rule overlap. + - uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them. + - ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice. + +How many strings are nice under these new rules? diff --git a/day6.c b/day6.c deleted file mode 100644 index 02d75e5..0000000 --- a/day6.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - -int main() { - int i, j, - rs, cs, re, ce, - numlights = 0, brightness = 0; - int** lights; int** lights2; - char istr[10]; - - lights = (int**) malloc(1000*sizeof(int*)); - lights2 = (int**) malloc(1000*sizeof(int*)); - for(i = 0; i < 1000; i++) { - lights[i] = (int*) malloc(1000*sizeof(int)); - memset(lights[i], 0, 1000); - lights2[i] = (int*) malloc(1000*sizeof(int)); - memset(lights2[i], 0, 1000); - } - - while(scanf("%s", istr) != EOF) { - if(strncmp(istr, "turn", 4) == 0) - scanf("%s %d,%d through %d,%d", istr, &rs, &cs, &re, &ce); - else - scanf("%d,%d through %d,%d", &rs, &cs, &re, &ce); - - if(strncmp(istr, "on", 2) == 0) { - for(i = rs; i <= re; i++) - for(j = cs; j <= ce; j++) { - lights[i][j] = 1; - lights2[i][j] += 1; - } - } else if(strncmp(istr, "off", 3) == 0) { - for(i = rs; i <= re; i++) - for(j = cs; j <= ce; j++) { - lights[i][j] = 0; - if(lights2[i][j]) lights2[i][j] -= 1; - } - } else if(strncmp(istr, "toggle", 6) == 0) { - for(i = rs; i <= re; i++) - for(j = cs; j <= ce; j++) { - lights[i][j] = !lights[i][j]; - lights2[i][j] += 2; - } - } - } - - for(i = 0; i < 1000; i++) - for(j = 0; j < 1000; j++) { - if(lights[i][j]) numlights++; - brightness += lights2[i][j]; - } - - printf("Number of lights that are on: %d\n", numlights); - printf("Total brightness: %d\n", brightness); - - for(i = 0; i < 1000; i++) { - free(lights[i]); - free(lights2[i]); - } - free(lights); - free(lights2); - - return 0; -} diff --git a/day6.input b/day6.input deleted file mode 100644 index 495311e..0000000 --- a/day6.input +++ /dev/null @@ -1,300 +0,0 @@ -turn off 660,55 through 986,197 -turn off 341,304 through 638,850 -turn off 199,133 through 461,193 -toggle 322,558 through 977,958 -toggle 537,781 through 687,941 -turn on 226,196 through 599,390 -turn on 240,129 through 703,297 -turn on 317,329 through 451,798 -turn on 957,736 through 977,890 -turn on 263,530 through 559,664 -turn on 158,270 through 243,802 -toggle 223,39 through 454,511 -toggle 544,218 through 979,872 -turn on 313,306 through 363,621 -toggle 173,401 through 496,407 -toggle 333,60 through 748,159 -turn off 87,577 through 484,608 -turn on 809,648 through 826,999 -toggle 352,432 through 628,550 -turn off 197,408 through 579,569 -turn off 1,629 through 802,633 -turn off 61,44 through 567,111 -toggle 880,25 through 903,973 -turn on 347,123 through 864,746 -toggle 728,877 through 996,975 -turn on 121,895 through 349,906 -turn on 888,547 through 931,628 -toggle 398,782 through 834,882 -turn on 966,850 through 989,953 -turn off 891,543 through 914,991 -toggle 908,77 through 916,117 -turn on 576,900 through 943,934 -turn off 580,170 through 963,206 -turn on 184,638 through 192,944 -toggle 940,147 through 978,730 -turn off 854,56 through 965,591 -toggle 717,172 through 947,995 -toggle 426,987 through 705,998 -turn on 987,157 through 992,278 -toggle 995,774 through 997,784 -turn off 796,96 through 845,182 -turn off 451,87 through 711,655 -turn off 380,93 through 968,676 -turn on 263,468 through 343,534 -turn on 917,936 through 928,959 -toggle 478,7 through 573,148 -turn off 428,339 through 603,624 -turn off 400,880 through 914,953 -toggle 679,428 through 752,779 -turn off 697,981 through 709,986 -toggle 482,566 through 505,725 -turn off 956,368 through 993,516 -toggle 735,823 through 783,883 -turn off 48,487 through 892,496 -turn off 116,680 through 564,819 -turn on 633,865 through 729,930 -turn off 314,618 through 571,922 -toggle 138,166 through 936,266 -turn on 444,732 through 664,960 -turn off 109,337 through 972,497 -turn off 51,432 through 77,996 -turn off 259,297 through 366,744 -toggle 801,130 through 917,544 -toggle 767,982 through 847,996 -turn on 216,507 through 863,885 -turn off 61,441 through 465,731 -turn on 849,970 through 944,987 -toggle 845,76 through 852,951 -toggle 732,615 through 851,936 -toggle 251,128 through 454,778 -turn on 324,429 through 352,539 -toggle 52,450 through 932,863 -turn off 449,379 through 789,490 -turn on 317,319 through 936,449 -toggle 887,670 through 957,838 -toggle 671,613 through 856,664 -turn off 186,648 through 985,991 -turn off 471,689 through 731,717 -toggle 91,331 through 750,758 -toggle 201,73 through 956,524 -toggle 82,614 through 520,686 -toggle 84,287 through 467,734 -turn off 132,367 through 208,838 -toggle 558,684 through 663,920 -turn on 237,952 through 265,997 -turn on 694,713 through 714,754 -turn on 632,523 through 862,827 -turn on 918,780 through 948,916 -turn on 349,586 through 663,976 -toggle 231,29 through 257,589 -toggle 886,428 through 902,993 -turn on 106,353 through 236,374 -turn on 734,577 through 759,684 -turn off 347,843 through 696,912 -turn on 286,699 through 964,883 -turn on 605,875 through 960,987 -turn off 328,286 through 869,461 -turn off 472,569 through 980,848 -toggle 673,573 through 702,884 -turn off 398,284 through 738,332 -turn on 158,50 through 284,411 -turn off 390,284 through 585,663 -turn on 156,579 through 646,581 -turn on 875,493 through 989,980 -toggle 486,391 through 924,539 -turn on 236,722 through 272,964 -toggle 228,282 through 470,581 -toggle 584,389 through 750,761 -turn off 899,516 through 900,925 -turn on 105,229 through 822,846 -turn off 253,77 through 371,877 -turn on 826,987 through 906,992 -turn off 13,152 through 615,931 -turn on 835,320 through 942,399 -turn on 463,504 through 536,720 -toggle 746,942 through 786,998 -turn off 867,333 through 965,403 -turn on 591,477 through 743,692 -turn off 403,437 through 508,908 -turn on 26,723 through 368,814 -turn on 409,485 through 799,809 -turn on 115,630 through 704,705 -turn off 228,183 through 317,220 -toggle 300,649 through 382,842 -turn off 495,365 through 745,562 -turn on 698,346 through 744,873 -turn on 822,932 through 951,934 -toggle 805,30 through 925,421 -toggle 441,152 through 653,274 -toggle 160,81 through 257,587 -turn off 350,781 through 532,917 -toggle 40,583 through 348,636 -turn on 280,306 through 483,395 -toggle 392,936 through 880,955 -toggle 496,591 through 851,934 -turn off 780,887 through 946,994 -turn off 205,735 through 281,863 -toggle 100,876 through 937,915 -turn on 392,393 through 702,878 -turn on 956,374 through 976,636 -toggle 478,262 through 894,775 -turn off 279,65 through 451,677 -turn on 397,541 through 809,847 -turn on 444,291 through 451,586 -toggle 721,408 through 861,598 -turn on 275,365 through 609,382 -turn on 736,24 through 839,72 -turn off 86,492 through 582,712 -turn on 676,676 through 709,703 -turn off 105,710 through 374,817 -toggle 328,748 through 845,757 -toggle 335,79 through 394,326 -toggle 193,157 through 633,885 -turn on 227,48 through 769,743 -toggle 148,333 through 614,568 -toggle 22,30 through 436,263 -toggle 547,447 through 688,969 -toggle 576,621 through 987,740 -turn on 711,334 through 799,515 -turn on 541,448 through 654,951 -toggle 792,199 through 798,990 -turn on 89,956 through 609,960 -toggle 724,433 through 929,630 -toggle 144,895 through 201,916 -toggle 226,730 through 632,871 -turn off 760,819 through 828,974 -toggle 887,180 through 940,310 -toggle 222,327 through 805,590 -turn off 630,824 through 885,963 -turn on 940,740 through 954,946 -turn on 193,373 through 779,515 -toggle 304,955 through 469,975 -turn off 405,480 through 546,960 -turn on 662,123 through 690,669 -turn off 615,238 through 750,714 -turn on 423,220 through 930,353 -turn on 329,769 through 358,970 -toggle 590,151 through 704,722 -turn off 884,539 through 894,671 -toggle 449,241 through 984,549 -toggle 449,260 through 496,464 -turn off 306,448 through 602,924 -turn on 286,805 through 555,901 -toggle 722,177 through 922,298 -toggle 491,554 through 723,753 -turn on 80,849 through 174,996 -turn off 296,561 through 530,856 -toggle 653,10 through 972,284 -toggle 529,236 through 672,614 -toggle 791,598 through 989,695 -turn on 19,45 through 575,757 -toggle 111,55 through 880,871 -turn off 197,897 through 943,982 -turn on 912,336 through 977,605 -toggle 101,221 through 537,450 -turn on 101,104 through 969,447 -toggle 71,527 through 587,717 -toggle 336,445 through 593,889 -toggle 214,179 through 575,699 -turn on 86,313 through 96,674 -toggle 566,427 through 906,888 -turn off 641,597 through 850,845 -turn on 606,524 through 883,704 -turn on 835,775 through 867,887 -toggle 547,301 through 897,515 -toggle 289,930 through 413,979 -turn on 361,122 through 457,226 -turn on 162,187 through 374,746 -turn on 348,461 through 454,675 -turn off 966,532 through 985,537 -turn on 172,354 through 630,606 -turn off 501,880 through 680,993 -turn off 8,70 through 566,592 -toggle 433,73 through 690,651 -toggle 840,798 through 902,971 -toggle 822,204 through 893,760 -turn off 453,496 through 649,795 -turn off 969,549 through 990,942 -turn off 789,28 through 930,267 -toggle 880,98 through 932,434 -toggle 568,674 through 669,753 -turn on 686,228 through 903,271 -turn on 263,995 through 478,999 -toggle 534,675 through 687,955 -turn off 342,434 through 592,986 -toggle 404,768 through 677,867 -toggle 126,723 through 978,987 -toggle 749,675 through 978,959 -turn off 445,330 through 446,885 -turn off 463,205 through 924,815 -turn off 417,430 through 915,472 -turn on 544,990 through 912,999 -turn off 201,255 through 834,789 -turn off 261,142 through 537,862 -turn off 562,934 through 832,984 -turn off 459,978 through 691,980 -turn off 73,911 through 971,972 -turn on 560,448 through 723,810 -turn on 204,630 through 217,854 -turn off 91,259 through 611,607 -turn on 877,32 through 978,815 -turn off 950,438 through 974,746 -toggle 426,30 through 609,917 -toggle 696,37 through 859,201 -toggle 242,417 through 682,572 -turn off 388,401 through 979,528 -turn off 79,345 through 848,685 -turn off 98,91 through 800,434 -toggle 650,700 through 972,843 -turn off 530,450 through 538,926 -turn on 428,559 through 962,909 -turn on 78,138 through 92,940 -toggle 194,117 through 867,157 -toggle 785,355 through 860,617 -turn off 379,441 through 935,708 -turn off 605,133 through 644,911 -toggle 10,963 through 484,975 -turn off 359,988 through 525,991 -turn off 509,138 through 787,411 -toggle 556,467 through 562,773 -turn on 119,486 through 246,900 -turn on 445,561 through 794,673 -turn off 598,681 through 978,921 -turn off 974,230 through 995,641 -turn off 760,75 through 800,275 -toggle 441,215 through 528,680 -turn off 701,636 through 928,877 -turn on 165,753 through 202,780 -toggle 501,412 through 998,516 -toggle 161,105 through 657,395 -turn on 113,340 through 472,972 -toggle 384,994 through 663,999 -turn on 969,994 through 983,997 -turn on 519,600 through 750,615 -turn off 363,899 through 948,935 -turn on 271,845 through 454,882 -turn off 376,528 through 779,640 -toggle 767,98 through 854,853 -toggle 107,322 through 378,688 -turn off 235,899 through 818,932 -turn on 445,611 through 532,705 -toggle 629,387 through 814,577 -toggle 112,414 through 387,421 -toggle 319,184 through 382,203 -turn on 627,796 through 973,940 -toggle 602,45 through 763,151 -turn off 441,375 through 974,545 -toggle 871,952 through 989,998 -turn on 717,272 through 850,817 -toggle 475,711 through 921,882 -toggle 66,191 through 757,481 -turn off 50,197 through 733,656 -toggle 83,575 through 915,728 -turn on 777,812 through 837,912 -turn on 20,984 through 571,994 -turn off 446,432 through 458,648 -turn on 715,871 through 722,890 -toggle 424,675 through 740,862 -toggle 580,592 through 671,900 -toggle 296,687 through 906,775 diff --git a/day6.readme b/day6.readme deleted file mode 100644 index ec5e980..0000000 --- a/day6.readme +++ /dev/null @@ -1,38 +0,0 @@ ---- Day 6: Probably a Fire Hazard --- - -Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to deploy one million lights in a 1000x1000 grid. - -Furthermore, because you've been especially nice this year, Santa has mailed you instructions on how to display the ideal lighting configuration. - -Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore refers to 9 lights in a 3x3 square. The lights all start turned off. - -To defeat your neighbors this year, all you have to do is set up your lights by doing the instructions Santa sent you in order. - -For example: - - - turn on 0,0 through 999,999 would turn on (or leave on) every light. - - toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones that were on, and turning on the ones that were off. - - turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. - -After following the instructions, how many lights are lit? - -Your puzzle answer was 400410. - ---- Part Two --- - -You just finish implementing your winning light pattern when you realize you mistranslated Santa's message from Ancient Nordic Elvish. - -The light grid you bought actually has individual brightness controls; each light can have a brightness of zero or more. The lights all start at zero. - -The phrase turn on actually means that you should increase the brightness of those lights by 1. - -The phrase turn off actually means that you should decrease the brightness of those lights by 1, to a minimum of zero. - -The phrase toggle actually means that you should increase the brightness of those lights by 2. - -What is the total brightness of all lights combined after following Santa's instructions? - -For example: - - - turn on 0,0 through 0,0 would increase the total brightness by 1. - - toggle 0,0 through 999,999 would increase the total brightness by 2000000. diff --git a/day6/Makefile b/day6/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/day6/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/day6/day6.c b/day6/day6.c new file mode 100644 index 0000000..02d75e5 --- /dev/null +++ b/day6/day6.c @@ -0,0 +1,65 @@ +#include +#include +#include + +int main() { + int i, j, + rs, cs, re, ce, + numlights = 0, brightness = 0; + int** lights; int** lights2; + char istr[10]; + + lights = (int**) malloc(1000*sizeof(int*)); + lights2 = (int**) malloc(1000*sizeof(int*)); + for(i = 0; i < 1000; i++) { + lights[i] = (int*) malloc(1000*sizeof(int)); + memset(lights[i], 0, 1000); + lights2[i] = (int*) malloc(1000*sizeof(int)); + memset(lights2[i], 0, 1000); + } + + while(scanf("%s", istr) != EOF) { + if(strncmp(istr, "turn", 4) == 0) + scanf("%s %d,%d through %d,%d", istr, &rs, &cs, &re, &ce); + else + scanf("%d,%d through %d,%d", &rs, &cs, &re, &ce); + + if(strncmp(istr, "on", 2) == 0) { + for(i = rs; i <= re; i++) + for(j = cs; j <= ce; j++) { + lights[i][j] = 1; + lights2[i][j] += 1; + } + } else if(strncmp(istr, "off", 3) == 0) { + for(i = rs; i <= re; i++) + for(j = cs; j <= ce; j++) { + lights[i][j] = 0; + if(lights2[i][j]) lights2[i][j] -= 1; + } + } else if(strncmp(istr, "toggle", 6) == 0) { + for(i = rs; i <= re; i++) + for(j = cs; j <= ce; j++) { + lights[i][j] = !lights[i][j]; + lights2[i][j] += 2; + } + } + } + + for(i = 0; i < 1000; i++) + for(j = 0; j < 1000; j++) { + if(lights[i][j]) numlights++; + brightness += lights2[i][j]; + } + + printf("Number of lights that are on: %d\n", numlights); + printf("Total brightness: %d\n", brightness); + + for(i = 0; i < 1000; i++) { + free(lights[i]); + free(lights2[i]); + } + free(lights); + free(lights2); + + return 0; +} diff --git a/day6/day6.input b/day6/day6.input new file mode 100644 index 0000000..495311e --- /dev/null +++ b/day6/day6.input @@ -0,0 +1,300 @@ +turn off 660,55 through 986,197 +turn off 341,304 through 638,850 +turn off 199,133 through 461,193 +toggle 322,558 through 977,958 +toggle 537,781 through 687,941 +turn on 226,196 through 599,390 +turn on 240,129 through 703,297 +turn on 317,329 through 451,798 +turn on 957,736 through 977,890 +turn on 263,530 through 559,664 +turn on 158,270 through 243,802 +toggle 223,39 through 454,511 +toggle 544,218 through 979,872 +turn on 313,306 through 363,621 +toggle 173,401 through 496,407 +toggle 333,60 through 748,159 +turn off 87,577 through 484,608 +turn on 809,648 through 826,999 +toggle 352,432 through 628,550 +turn off 197,408 through 579,569 +turn off 1,629 through 802,633 +turn off 61,44 through 567,111 +toggle 880,25 through 903,973 +turn on 347,123 through 864,746 +toggle 728,877 through 996,975 +turn on 121,895 through 349,906 +turn on 888,547 through 931,628 +toggle 398,782 through 834,882 +turn on 966,850 through 989,953 +turn off 891,543 through 914,991 +toggle 908,77 through 916,117 +turn on 576,900 through 943,934 +turn off 580,170 through 963,206 +turn on 184,638 through 192,944 +toggle 940,147 through 978,730 +turn off 854,56 through 965,591 +toggle 717,172 through 947,995 +toggle 426,987 through 705,998 +turn on 987,157 through 992,278 +toggle 995,774 through 997,784 +turn off 796,96 through 845,182 +turn off 451,87 through 711,655 +turn off 380,93 through 968,676 +turn on 263,468 through 343,534 +turn on 917,936 through 928,959 +toggle 478,7 through 573,148 +turn off 428,339 through 603,624 +turn off 400,880 through 914,953 +toggle 679,428 through 752,779 +turn off 697,981 through 709,986 +toggle 482,566 through 505,725 +turn off 956,368 through 993,516 +toggle 735,823 through 783,883 +turn off 48,487 through 892,496 +turn off 116,680 through 564,819 +turn on 633,865 through 729,930 +turn off 314,618 through 571,922 +toggle 138,166 through 936,266 +turn on 444,732 through 664,960 +turn off 109,337 through 972,497 +turn off 51,432 through 77,996 +turn off 259,297 through 366,744 +toggle 801,130 through 917,544 +toggle 767,982 through 847,996 +turn on 216,507 through 863,885 +turn off 61,441 through 465,731 +turn on 849,970 through 944,987 +toggle 845,76 through 852,951 +toggle 732,615 through 851,936 +toggle 251,128 through 454,778 +turn on 324,429 through 352,539 +toggle 52,450 through 932,863 +turn off 449,379 through 789,490 +turn on 317,319 through 936,449 +toggle 887,670 through 957,838 +toggle 671,613 through 856,664 +turn off 186,648 through 985,991 +turn off 471,689 through 731,717 +toggle 91,331 through 750,758 +toggle 201,73 through 956,524 +toggle 82,614 through 520,686 +toggle 84,287 through 467,734 +turn off 132,367 through 208,838 +toggle 558,684 through 663,920 +turn on 237,952 through 265,997 +turn on 694,713 through 714,754 +turn on 632,523 through 862,827 +turn on 918,780 through 948,916 +turn on 349,586 through 663,976 +toggle 231,29 through 257,589 +toggle 886,428 through 902,993 +turn on 106,353 through 236,374 +turn on 734,577 through 759,684 +turn off 347,843 through 696,912 +turn on 286,699 through 964,883 +turn on 605,875 through 960,987 +turn off 328,286 through 869,461 +turn off 472,569 through 980,848 +toggle 673,573 through 702,884 +turn off 398,284 through 738,332 +turn on 158,50 through 284,411 +turn off 390,284 through 585,663 +turn on 156,579 through 646,581 +turn on 875,493 through 989,980 +toggle 486,391 through 924,539 +turn on 236,722 through 272,964 +toggle 228,282 through 470,581 +toggle 584,389 through 750,761 +turn off 899,516 through 900,925 +turn on 105,229 through 822,846 +turn off 253,77 through 371,877 +turn on 826,987 through 906,992 +turn off 13,152 through 615,931 +turn on 835,320 through 942,399 +turn on 463,504 through 536,720 +toggle 746,942 through 786,998 +turn off 867,333 through 965,403 +turn on 591,477 through 743,692 +turn off 403,437 through 508,908 +turn on 26,723 through 368,814 +turn on 409,485 through 799,809 +turn on 115,630 through 704,705 +turn off 228,183 through 317,220 +toggle 300,649 through 382,842 +turn off 495,365 through 745,562 +turn on 698,346 through 744,873 +turn on 822,932 through 951,934 +toggle 805,30 through 925,421 +toggle 441,152 through 653,274 +toggle 160,81 through 257,587 +turn off 350,781 through 532,917 +toggle 40,583 through 348,636 +turn on 280,306 through 483,395 +toggle 392,936 through 880,955 +toggle 496,591 through 851,934 +turn off 780,887 through 946,994 +turn off 205,735 through 281,863 +toggle 100,876 through 937,915 +turn on 392,393 through 702,878 +turn on 956,374 through 976,636 +toggle 478,262 through 894,775 +turn off 279,65 through 451,677 +turn on 397,541 through 809,847 +turn on 444,291 through 451,586 +toggle 721,408 through 861,598 +turn on 275,365 through 609,382 +turn on 736,24 through 839,72 +turn off 86,492 through 582,712 +turn on 676,676 through 709,703 +turn off 105,710 through 374,817 +toggle 328,748 through 845,757 +toggle 335,79 through 394,326 +toggle 193,157 through 633,885 +turn on 227,48 through 769,743 +toggle 148,333 through 614,568 +toggle 22,30 through 436,263 +toggle 547,447 through 688,969 +toggle 576,621 through 987,740 +turn on 711,334 through 799,515 +turn on 541,448 through 654,951 +toggle 792,199 through 798,990 +turn on 89,956 through 609,960 +toggle 724,433 through 929,630 +toggle 144,895 through 201,916 +toggle 226,730 through 632,871 +turn off 760,819 through 828,974 +toggle 887,180 through 940,310 +toggle 222,327 through 805,590 +turn off 630,824 through 885,963 +turn on 940,740 through 954,946 +turn on 193,373 through 779,515 +toggle 304,955 through 469,975 +turn off 405,480 through 546,960 +turn on 662,123 through 690,669 +turn off 615,238 through 750,714 +turn on 423,220 through 930,353 +turn on 329,769 through 358,970 +toggle 590,151 through 704,722 +turn off 884,539 through 894,671 +toggle 449,241 through 984,549 +toggle 449,260 through 496,464 +turn off 306,448 through 602,924 +turn on 286,805 through 555,901 +toggle 722,177 through 922,298 +toggle 491,554 through 723,753 +turn on 80,849 through 174,996 +turn off 296,561 through 530,856 +toggle 653,10 through 972,284 +toggle 529,236 through 672,614 +toggle 791,598 through 989,695 +turn on 19,45 through 575,757 +toggle 111,55 through 880,871 +turn off 197,897 through 943,982 +turn on 912,336 through 977,605 +toggle 101,221 through 537,450 +turn on 101,104 through 969,447 +toggle 71,527 through 587,717 +toggle 336,445 through 593,889 +toggle 214,179 through 575,699 +turn on 86,313 through 96,674 +toggle 566,427 through 906,888 +turn off 641,597 through 850,845 +turn on 606,524 through 883,704 +turn on 835,775 through 867,887 +toggle 547,301 through 897,515 +toggle 289,930 through 413,979 +turn on 361,122 through 457,226 +turn on 162,187 through 374,746 +turn on 348,461 through 454,675 +turn off 966,532 through 985,537 +turn on 172,354 through 630,606 +turn off 501,880 through 680,993 +turn off 8,70 through 566,592 +toggle 433,73 through 690,651 +toggle 840,798 through 902,971 +toggle 822,204 through 893,760 +turn off 453,496 through 649,795 +turn off 969,549 through 990,942 +turn off 789,28 through 930,267 +toggle 880,98 through 932,434 +toggle 568,674 through 669,753 +turn on 686,228 through 903,271 +turn on 263,995 through 478,999 +toggle 534,675 through 687,955 +turn off 342,434 through 592,986 +toggle 404,768 through 677,867 +toggle 126,723 through 978,987 +toggle 749,675 through 978,959 +turn off 445,330 through 446,885 +turn off 463,205 through 924,815 +turn off 417,430 through 915,472 +turn on 544,990 through 912,999 +turn off 201,255 through 834,789 +turn off 261,142 through 537,862 +turn off 562,934 through 832,984 +turn off 459,978 through 691,980 +turn off 73,911 through 971,972 +turn on 560,448 through 723,810 +turn on 204,630 through 217,854 +turn off 91,259 through 611,607 +turn on 877,32 through 978,815 +turn off 950,438 through 974,746 +toggle 426,30 through 609,917 +toggle 696,37 through 859,201 +toggle 242,417 through 682,572 +turn off 388,401 through 979,528 +turn off 79,345 through 848,685 +turn off 98,91 through 800,434 +toggle 650,700 through 972,843 +turn off 530,450 through 538,926 +turn on 428,559 through 962,909 +turn on 78,138 through 92,940 +toggle 194,117 through 867,157 +toggle 785,355 through 860,617 +turn off 379,441 through 935,708 +turn off 605,133 through 644,911 +toggle 10,963 through 484,975 +turn off 359,988 through 525,991 +turn off 509,138 through 787,411 +toggle 556,467 through 562,773 +turn on 119,486 through 246,900 +turn on 445,561 through 794,673 +turn off 598,681 through 978,921 +turn off 974,230 through 995,641 +turn off 760,75 through 800,275 +toggle 441,215 through 528,680 +turn off 701,636 through 928,877 +turn on 165,753 through 202,780 +toggle 501,412 through 998,516 +toggle 161,105 through 657,395 +turn on 113,340 through 472,972 +toggle 384,994 through 663,999 +turn on 969,994 through 983,997 +turn on 519,600 through 750,615 +turn off 363,899 through 948,935 +turn on 271,845 through 454,882 +turn off 376,528 through 779,640 +toggle 767,98 through 854,853 +toggle 107,322 through 378,688 +turn off 235,899 through 818,932 +turn on 445,611 through 532,705 +toggle 629,387 through 814,577 +toggle 112,414 through 387,421 +toggle 319,184 through 382,203 +turn on 627,796 through 973,940 +toggle 602,45 through 763,151 +turn off 441,375 through 974,545 +toggle 871,952 through 989,998 +turn on 717,272 through 850,817 +toggle 475,711 through 921,882 +toggle 66,191 through 757,481 +turn off 50,197 through 733,656 +toggle 83,575 through 915,728 +turn on 777,812 through 837,912 +turn on 20,984 through 571,994 +turn off 446,432 through 458,648 +turn on 715,871 through 722,890 +toggle 424,675 through 740,862 +toggle 580,592 through 671,900 +toggle 296,687 through 906,775 diff --git a/day6/day6.readme b/day6/day6.readme new file mode 100644 index 0000000..ec5e980 --- /dev/null +++ b/day6/day6.readme @@ -0,0 +1,38 @@ +--- Day 6: Probably a Fire Hazard --- + +Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to deploy one million lights in a 1000x1000 grid. + +Furthermore, because you've been especially nice this year, Santa has mailed you instructions on how to display the ideal lighting configuration. + +Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore refers to 9 lights in a 3x3 square. The lights all start turned off. + +To defeat your neighbors this year, all you have to do is set up your lights by doing the instructions Santa sent you in order. + +For example: + + - turn on 0,0 through 999,999 would turn on (or leave on) every light. + - toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones that were on, and turning on the ones that were off. + - turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. + +After following the instructions, how many lights are lit? + +Your puzzle answer was 400410. + +--- Part Two --- + +You just finish implementing your winning light pattern when you realize you mistranslated Santa's message from Ancient Nordic Elvish. + +The light grid you bought actually has individual brightness controls; each light can have a brightness of zero or more. The lights all start at zero. + +The phrase turn on actually means that you should increase the brightness of those lights by 1. + +The phrase turn off actually means that you should decrease the brightness of those lights by 1, to a minimum of zero. + +The phrase toggle actually means that you should increase the brightness of those lights by 2. + +What is the total brightness of all lights combined after following Santa's instructions? + +For example: + + - turn on 0,0 through 0,0 would increase the total brightness by 1. + - toggle 0,0 through 999,999 would increase the total brightness by 2000000. diff --git a/readme.textile b/readme.textile index 0f7a6fa..443a7e4 100644 --- a/readme.textile +++ b/readme.textile @@ -1,3 +1,8 @@ h1. Advent of Code - This repo contains my code for the "Advent of Code":http://adventofcode.com/. + +h2. Building the solver +To build any solver, run `make` in that directory. + +h2. Getting the solution +To solve the problem, run it with `make run` or `time make run`. -- cgit v1.2.1