diff --git a/d04/run.c b/d04/run.c new file mode 100644 index 0000000..ab185f6 --- /dev/null +++ b/d04/run.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +/** + compile with `tcc -lssl run.c` + run with `./a.out | grep -F ' 000000'`, then CTRL+C + */ +void main(int argc, char **argv) { + unsigned char digest[16]; + char string[32]; + MD5_CTX context; + for (int i=1;;i++) { + printf("%d ",i); + sprintf(string,"ckczppom%d",i); + MD5_Init(&context); + MD5_Update(&context, string, strlen(string)); + MD5_Final(digest, &context); + for(int i = 0; i < 16; ++i) { + printf("%02x", (unsigned int)digest[i]); + } + printf("\n"); + } +} diff --git a/d05/run.py b/d05/run.py new file mode 100644 index 0000000..f508fde --- /dev/null +++ b/d05/run.py @@ -0,0 +1,17 @@ +import sys + +def isnice1(l): + if any(a+b in ['ab','cd','pq','xy'] for (a,b) in zip(l,l[1:])): + return False + vowels = sum(c in 'aeiou' for c in l) + inarow = any(a==b for (a,b) in zip(l,l[1:])) + return vowels > 2 and inarow + +def isnice2(l): + xyxy = any(l[i:i+2] == l[j:j+2] for i in range(len(l)-1) for j in range(i+2,len(l)-1)) + gfg = any(a == b for a,b in zip(l[0:],l[2:])) + return xyxy and gfg + +isnice = isnice2 if sys.argv[1] == "2" else isnice1 + +print(sum(isnice(l[:-1]) for l in sys.stdin.readlines())) diff --git a/d06/part1.py b/d06/part1.py new file mode 100644 index 0000000..291b262 --- /dev/null +++ b/d06/part1.py @@ -0,0 +1,18 @@ +import sys + +M = [[False for _ in range(1000)] for _ in range(1000)] + +for l in sys.stdin.readlines(): + I = l[:-1].split(' ') + xf,yf = list(map(int,I[-3].split(','))) + xt,yt = list(map(int,I[-1].split(','))) + for x in range(xf,xt+1): + for y in range(yf,yt+1): + if I[-4] == 'on': + M[x][y] = True + elif I[-4] == 'off': + M[x][y] = False + else: + M[x][y] = not M[x][y] + +print(sum(x for C in M for x in C)) diff --git a/d06/part2.py b/d06/part2.py new file mode 100644 index 0000000..003b0f4 --- /dev/null +++ b/d06/part2.py @@ -0,0 +1,18 @@ +import sys + +M = [[0 for _ in range(1000)] for _ in range(1000)] + +for l in sys.stdin.readlines(): + I = l[:-1].split(' ') + xf,yf = list(map(int,I[-3].split(','))) + xt,yt = list(map(int,I[-1].split(','))) + for x in range(xf,xt+1): + for y in range(yf,yt+1): + if I[-4] == 'on': + M[x][y] += 1 + elif I[-4] == 'off': + M[x][y] = max(0, M[x][y]-1) + else: + M[x][y] += 2 + +print(sum(x for C in M for x in C))