summaryrefslogtreecommitdiffstats
path: root/solutions/py/d04.py
diff options
context:
space:
mode:
Diffstat (limited to 'solutions/py/d04.py')
-rw-r--r--solutions/py/d04.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/solutions/py/d04.py b/solutions/py/d04.py
new file mode 100644
index 0000000..3115f2a
--- /dev/null
+++ b/solutions/py/d04.py
@@ -0,0 +1,45 @@
+from collections import Counter
+
+def isIncreasing(num):
+ s = str(num)
+ n = int(s[0])
+ for sp in s[1:]:
+ if int(sp) < n:
+ return False
+ n = int(sp)
+ return True
+
+def pt1(input):
+ return
+ def containsDouble(num):
+ s = str(num)
+ amounts = []
+ for n in (0,1,2,3,4,5,6,7,8,9):
+ amounts.append(s.count(str(n)))
+ c = Counter(amounts)
+ return c[0] + c[1] < 10
+
+ amount = 0
+ for n in range(357253, 892942 + 1):
+ if containsDouble(n):
+ if isIncreasing(n):
+ amount += 1
+ return amount
+
+def pt2(input):
+ return
+ def containsDouble(num):
+ s = str(num)
+ amounts = []
+ for n in (0,1,2,3,4,5,6,7,8,9):
+ amounts.append(s.count(str(n)))
+ c = Counter(amounts)
+ if c[0] + c[1] < 10:
+ return c[2] >= 1
+ amount = 0
+ for n in range(357253, 892942 + 1):
+ if containsDouble(n):
+ if isIncreasing(n):
+ amount += 1
+ return amount
+