summaryrefslogtreecommitdiff
path: root/2018/aoc18-d04-1.py
diff options
context:
space:
mode:
authorihaveslowbrain <gitserver@ihaveslowbrain.com>2023-10-20 21:32:41 +0000
committerihaveslowbrain <gitserver@ihaveslowbrain.com>2023-10-20 21:32:41 +0000
commitd7fef5244c43526e4f1102f816130f55cf20e8a7 (patch)
treef8668a90bcb9abb34f94ced31900151348f39998 /2018/aoc18-d04-1.py
parent61073dcec8e896b84fafbd6110e2da55a0dd2d5e (diff)
renamed few files
Diffstat (limited to '2018/aoc18-d04-1.py')
-rw-r--r--2018/aoc18-d04-1.py123
1 files changed, 0 insertions, 123 deletions
diff --git a/2018/aoc18-d04-1.py b/2018/aoc18-d04-1.py
deleted file mode 100644
index 6f28be5..0000000
--- a/2018/aoc18-d04-1.py
+++ /dev/null
@@ -1,123 +0,0 @@
-import numpy as np
-
-
-def datecompact(log):
- d = log[1:5] + log[6:8] + log[9:11] + log[12:14] + log[15:17];
- return int(d);
-
-def action(log):
- if (log[19] == "f"):
- return 1;
- elif (log[19] == "w"):
- return 2;
- else:
- #return 3;
- return int(log[24:].strip("\n # begins shift"));
- return (log[24:].strip("\n # begins shift"));
- #return int(log[24:].strip("#beginshft\n"));
-
-f = open("input");
-#f = open("testinput");
-
-myinput = [];
-guards = {};
-
-for i in f:
- #print(datecompact(i));
- myinput.append([datecompact(i),action(i)]);
- if (action(i) != 1 and action(i) != 2 ):
- try:
- guards[action(i)] = 0;
- except:
- True;
-
-
-for i in range(len(myinput)):
- #print(i[0], " -- ", i[1]);
- for j in range(len(myinput)):
- if (myinput[i][0] < myinput[j][0]):
- temp = myinput[i];
- myinput[i] = myinput[j];
- myinput[j] = temp;
-
-
-#print(guards);
-
-#for i in range(len(myinput) -1):
- #if (myinput[i][0] > myinput[i+1][0]):
- #print("fuck");
-#for i in myinput:
-# print(i[0], " -- ", i[1]);
-
-x1 = 0;
-
-
-for l in myinput:
- if l[1] == 2:
- guards[g] += l[0] - x1 ;
- elif l[1] == 1:
- x1 = l[0];
- else:
- g = l[1];
-
-
-tmax = 0;
-bestg = "";
-
-for g in guards.keys():
- print(g);
- #'''
- if (guards[g] >tmax):
- tmax = guards[g];
- bestg = g;
- #'''
-
-print("best guard ",bestg," - ", tmax);
-#part1 = int(bestg)*tmax;
-#print("part1", part1);
-
-#269357 too high
-#256332 too high
-
-
-
-is_bestg = False;
-
-#timestat = np.array(60);
-#timestat.fill(0);
-timestat = np.full(60,0, dtype=int);
-
-#bestg = int(bestg);
-
-for l in myinput:
- print("iterating", l[0], " ", l[1], " ", l[0]%100);
-
- if (is_bestg and (l[1] == 1 or l[1] == 2)):
- print("yup");
- if l[1] == 1:
- t1 = l[0];
- elif l[1] == 2:
- t2 = l[0];
- for t in range(t1%100,t2%100,1):
- timestat[t] += 1;
- elif l[1] == bestg:
- is_bestg = True;
- elif l[1] != bestg:
- print("not bestg");
- is_bestg = False;
-
-'''
- guards[g] += l[0] - x1 ;
- elif l[1] == 1:
- x1 = l[0];
- else:
- g = l[1];
-'''
-
-worsttime = (np.argmax(timestat));
-
-part1 = int(bestg)*worsttime;
-
-
-print("best guard ",bestg," - ", worsttime);
-print("part1", part1);