summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--solutions/py/d01.py9
-rw-r--r--solutions/py/d02.py8
-rw-r--r--solutions/py/d03.py9
-rw-r--r--solutions/py/d04.py1
-rw-r--r--solutions/py/d05.py8
-rw-r--r--solutions/py/d06.py9
-rw-r--r--solutions/py/d07.py8
-rw-r--r--solutions/py/d08.py10
8 files changed, 60 insertions, 2 deletions
diff --git a/solutions/py/d01.py b/solutions/py/d01.py
index d5197ab..d1c57c8 100644
--- a/solutions/py/d01.py
+++ b/solutions/py/d01.py
@@ -17,3 +17,12 @@ def pt1(_in):
def pt2(input):
return sum([get_fuel(int(line)) for line in input])
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/01", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/solutions/py/d02.py b/solutions/py/d02.py
index 15f0fea..c1889c1 100644
--- a/solutions/py/d02.py
+++ b/solutions/py/d02.py
@@ -39,3 +39,11 @@ def pt2(input):
if memory[0] == 19690720:
return (n, v)
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/02", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/solutions/py/d03.py b/solutions/py/d03.py
index aec6d4a..2454cb3 100644
--- a/solutions/py/d03.py
+++ b/solutions/py/d03.py
@@ -73,3 +73,12 @@ def pt2(input):
for point in points[1:]:
length = min(length, wire1[point] + wire2[point])
return length
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/03", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/solutions/py/d04.py b/solutions/py/d04.py
index 6b2af1d..1d5840a 100644
--- a/solutions/py/d04.py
+++ b/solutions/py/d04.py
@@ -44,5 +44,6 @@ def pt2(input):
if __name__ == "__main__":
import cProfile
+
cProfile.run("pt1([])")
cProfile.run("pt2([])")
diff --git a/solutions/py/d05.py b/solutions/py/d05.py
index 446bcd6..1415b99 100644
--- a/solutions/py/d05.py
+++ b/solutions/py/d05.py
@@ -24,3 +24,11 @@ def pt2(input):
c.output = None
return output
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/05", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/solutions/py/d06.py b/solutions/py/d06.py
index b6b9ef7..0b54362 100644
--- a/solutions/py/d06.py
+++ b/solutions/py/d06.py
@@ -76,3 +76,12 @@ def pt2(input):
tar_dist += 1
if src_parent == tar_parent:
return (src_parent.name, src_dist, tar_dist, src_dist + tar_dist)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/06", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/solutions/py/d07.py b/solutions/py/d07.py
index e12d7c9..c39e811 100644
--- a/solutions/py/d07.py
+++ b/solutions/py/d07.py
@@ -68,3 +68,11 @@ def pt2(input):
highest_signal = signal
highest_sequence = phase_seq
return (highest_sequence, highest_signal)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/07", "r").readlines()
+ pt1(input)
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
diff --git a/solutions/py/d08.py b/solutions/py/d08.py
index 659bc3a..07a5af3 100644
--- a/solutions/py/d08.py
+++ b/solutions/py/d08.py
@@ -1,13 +1,11 @@
def count(layer, num):
return sum([row.count(num) for row in layer])
-
def pt1(input):
img = []
least_zeroes = 150 # max
n = 0
for l in range(100):
- #print("l", l)
layer = [[int(input[0][l*25*6 + y*25 + x]) for x in range(25)] for y in range(6)]
if count(layer, 0) < least_zeroes:
least_zeroes = count(layer, 0)
@@ -29,3 +27,11 @@ def pt2(input):
str_res.append('\u2588' if c == 1 else ' ')
str_res.append("\n")
return "\n" + ("".join(str_res))
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/08", "r").readlines()
+ pt1(input)
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")