Explorar el Código

2020/2

master
Roderic Day hace 4 años
padre
commit
9aae9a8ec0
Se han modificado 1 ficheros con 10 adiciones y 1 borrados
  1. +10
    -1
      y2020/p02.py

+ 10
- 1
y2020/p02.py Ver fichero

@@ -1,4 +1,13 @@
import re
import sys


sys.stdin.read().splitlines()
ans1 = 0
ans2 = 0
for line in sys.stdin.read().splitlines():
lo, hi, char, pw = re.findall(r'(\d+)-(\d+) (\w): (\w+)', line)[0]
lo, hi = int(lo), int(hi)
ans1 += lo <= pw.count(char) <= hi
ans2 += sum([pw[lo - 1] == char, pw[hi - 1] == char]) == 1
print(ans1)
print(ans2)

Cargando…
Cancelar
Guardar