aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile17
l---------day1/Makefile1
-rw-r--r--day1/day1.c (renamed from day1.c)0
-rw-r--r--day1/day1.input (renamed from day1.input)0
-rw-r--r--day1/day1.readme (renamed from day1.readme)0
l---------day2/Makefile1
-rw-r--r--day2/day2.c (renamed from day2.c)0
-rw-r--r--day2/day2.input (renamed from day2.input)0
-rw-r--r--day2/day2.readme (renamed from day2.readme)0
l---------day3/Makefile1
-rw-r--r--day3/day3.c (renamed from day3.c)0
-rw-r--r--day3/day3.input (renamed from day3.input)0
-rw-r--r--day3/day3.readme (renamed from day3.readme)0
l---------day4/Makefile1
-rw-r--r--day4/day4.c (renamed from day4.c)7
-rw-r--r--day4/day4.input2
-rw-r--r--day4/day4.readme (renamed from day4.readme)0
-rw-r--r--day4/override.mk1
l---------day5/Makefile1
-rw-r--r--day5/day5.c (renamed from day5.c)0
-rw-r--r--day5/day5.input (renamed from day5.input)0
-rw-r--r--day5/day5.readme (renamed from day5.readme)0
l---------day6/Makefile1
-rw-r--r--day6/day6.c (renamed from day6.c)0
-rw-r--r--day6/day6.input (renamed from day6.input)0
-rw-r--r--day6/day6.readme (renamed from day6.readme)0
-rw-r--r--readme.textile7
27 files changed, 37 insertions, 3 deletions
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/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.c b/day1/day1.c
index dbd188d..dbd188d 100644
--- a/day1.c
+++ b/day1/day1.c
diff --git a/day1.input b/day1/day1.input
index becde71..becde71 100644
--- a/day1.input
+++ b/day1/day1.input
diff --git a/day1.readme b/day1/day1.readme
index 0da69d3..0da69d3 100644
--- a/day1.readme
+++ b/day1/day1.readme
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.c b/day2/day2.c
index d02526f..d02526f 100644
--- a/day2.c
+++ b/day2/day2.c
diff --git a/day2.input b/day2/day2.input
index b52434e..b52434e 100644
--- a/day2.input
+++ b/day2/day2.input
diff --git a/day2.readme b/day2/day2.readme
index d329683..d329683 100644
--- a/day2.readme
+++ b/day2/day2.readme
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.c b/day3/day3.c
index 7179be6..7179be6 100644
--- a/day3.c
+++ b/day3/day3.c
diff --git a/day3.input b/day3/day3.input
index f7791cc..f7791cc 100644
--- a/day3.input
+++ b/day3/day3.input
diff --git a/day3.readme b/day3/day3.readme
index 66077b3..66077b3 100644
--- a/day3.readme
+++ b/day3/day3.readme
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.c b/day4/day4.c
index ae3fb94..339ea1a 100644
--- a/day4.c
+++ b/day4/day4.c
@@ -3,8 +3,8 @@
#include <string.h>
#include <openssl/md5.h>
-unsigned char* secret = "iwrupvqb";
-unsigned char* target = "000000";
+unsigned char secret[10];
+unsigned char target[10];
unsigned char result[MD5_DIGEST_LENGTH];
void hash(int i) {
@@ -36,6 +36,9 @@ int check(int len) {
int main() {
int i = 1, got5 = 0, got6 = 0;
+ scanf("%s", secret);
+ scanf("%s", target);
+
while(!(got5 && got6)) {
hash(i);
if(!got5 && check(5)) {
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.readme b/day4/day4.readme
index b629160..b629160 100644
--- a/day4.readme
+++ b/day4/day4.readme
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/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.c b/day5/day5.c
index 3d737b2..3d737b2 100644
--- a/day5.c
+++ b/day5/day5.c
diff --git a/day5.input b/day5/day5.input
index a9b6e77..a9b6e77 100644
--- a/day5.input
+++ b/day5/day5.input
diff --git a/day5.readme b/day5/day5.readme
index 611dc87..611dc87 100644
--- a/day5.readme
+++ b/day5/day5.readme
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.c b/day6/day6.c
index 02d75e5..02d75e5 100644
--- a/day6.c
+++ b/day6/day6.c
diff --git a/day6.input b/day6/day6.input
index 495311e..495311e 100644
--- a/day6.input
+++ b/day6/day6.input
diff --git a/day6.readme b/day6/day6.readme
index ec5e980..ec5e980 100644
--- a/day6.readme
+++ b/day6/day6.readme
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`.