about summary refs log tree commit diff
path: root/users/Profpatsch/advent-of-code/2020/02/main.py
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2024-10-05T12·18+0200
committerProfpatsch <mail@profpatsch.de>2024-10-05T13·49+0000
commitc925902015b163706f860b7540148fb6302d98dd (patch)
treeee062bfcfa924abfafaf04aabbec28ff0eb12bd8 /users/Profpatsch/advent-of-code/2020/02/main.py
parent9c8087d705456ab6a0ec12a30a63e54cf3d8b0f2 (diff)
chore(users/Profpatsch): remove AoC stuff r/8771
Change-Id: Ifb134053c0f92dfdb4f2c0a3418c0c6a7a1a8507
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12574
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/advent-of-code/2020/02/main.py')
-rw-r--r--users/Profpatsch/advent-of-code/2020/02/main.py77
1 files changed, 0 insertions, 77 deletions
diff --git a/users/Profpatsch/advent-of-code/2020/02/main.py b/users/Profpatsch/advent-of-code/2020/02/main.py
deleted file mode 100644
index e3b27c382a21..000000000000
--- a/users/Profpatsch/advent-of-code/2020/02/main.py
+++ /dev/null
@@ -1,77 +0,0 @@
-import sys
-
-def parse(line):
-    a = line.split(sep=" ", maxsplit=1)
-    assert len(a) == 2
-    fromto = a[0].split(sep="-")
-    assert len(fromto) == 2
-    (from_, to) = (int(fromto[0]), int(fromto[1]))
-    charpass = a[1].split(sep=": ")
-    assert len(charpass) == 2
-    char = charpass[0]
-    assert len(char) == 1
-    pass_ = charpass[1]
-    assert pass_.endswith("\n")
-    pass_ = pass_[:-1]
-    return {
-        "from": from_,
-        "to": to,
-        "char": char,
-        "pass": pass_
-    }
-
-def char_in_pass(char, pass_):
-    return pass_.count(char)
-
-def validate_01(entry):
-    no = char_in_pass(entry["char"], entry["pass"])
-    if no < entry["from"]:
-        return { "too-small": entry }
-    elif no > entry["to"]:
-        return { "too-big": entry }
-    else:
-        return { "ok": entry }
-
-def char_at_pos(char, pos, pass_):
-    assert pos <= len(pass_)
-    return pass_[pos-1] == char
-
-def validate_02(entry):
-    one = char_at_pos(entry["char"], entry["from"], entry["pass"])
-    two = char_at_pos(entry["char"], entry["to"], entry["pass"])
-    if one and two:
-        return { "both": entry }
-    elif one:
-        return { "one": entry }
-    elif two:
-        return { "two": entry }
-    else:
-        return { "none": entry }
-
-
-res01 = []
-res02 = []
-with open("./input", 'r') as f:
-    for line in f:
-        p = parse(line)
-        res01.append(validate_01(p))
-        res02.append(validate_02(p))
-
-count01=0
-for r in res01:
-    print(r)
-    if r.get("ok", False):
-        count01=count01+1
-
-count02=0
-for r in res02:
-    print(r)
-    if r.get("one", False):
-        count02=count02+1
-    elif r.get("two", False):
-        count02=count02+1
-    else:
-        pass
-
-print("count 1: {}".format(count01))
-print("count 2: {}".format(count02))