Noëlle пре 3 година
родитељ
комит
aff6cc713b
2 измењених фајлова са 2 додато и 58 уклоњено
  1. 1
    53
      day4a.py
  2. 1
    5
      day4b.py

+ 1
- 53
day4a.py Прегледај датотеку

if v not in k: if v not in k:
print(f"Missing {v}.") print(f"Missing {v}.")
return False return False
# byr = ppt["byr"]
# byrm = re.match(r"^(\d{4})$", byr)
# if byrm == None:
# print(f"Bad BYR: {byr}.")
# return False
# byrn = int(byrm[1])
# if byrn < 1920 or byrn > 2002:
# print(f"Bad BYR: {byr}.")
# return False
# iyr = ppt["iyr"]
# iyrm = re.match(r"^(\d{4})$", iyr)
# if iyrm == None:
# print(f"Bad IYR: {iyr}.")
# return False
# iyrn = int(iyrm[1])
# if iyrn < 2010 or iyrn > 2020:
# print(f"Bad IYR: {iyr}.")
# return False
# eyr = ppt["eyr"]
# eyrm = re.match(r"^(\d{4})$", eyr)
# if eyrm == None:
# print(f"Bad EYR: {eyr}.")
# return False
# eyrn = int(eyrm[1])
# if eyrn < 2020 or eyrn > 2030:
# print(f"Bad EYR: {eyr}.")
# return False
# hgt = ppt["hgt"]
# hgtm = re.match(r"^(\d{2,3})(cm|in)$", hgt)
# if hgtm == None:
# print(f"Bad HGT: {hgt}.")
# return False
# hgtn = int(hgtm[1])
# hgtu = hgtm[2]
# if (hgtu == "cm" and (hgtn < 150 or hgtn > 193)) or (hgtu == "in" and (hgtn < 59 or hgtn > 76)):
# print(f"Bad HGT: {hgt}.")
# return False
# hcl = ppt["hcl"]
# if re.search(r"^#[0-9a-f]{6}$", hcl) == None:
# print(f"Bad HCL: {hcl}.")
# return False
# ecl = ppt["ecl"]
# if ecl not in ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]:
# print(f"Bad ECL: {ecl}.")
# return False
# pid = ppt["pid"]
# if re.search(r"^[0-9]{9}$", pid) == None:
# print(f"Bad PID: {pid}.")
# return False

return True return True


def main(): def main():
pptchunks = ppt.split(" ") pptchunks = ppt.split(" ")
pptdct = {} pptdct = {}
for chunk in pptchunks: for chunk in pptchunks:
try:
if chunk != "":
bits = chunk.split(":") bits = chunk.split(":")
pptdct[bits[0]] = bits[1] pptdct[bits[0]] = bits[1]
except:
print(ppt)
# print(ppt) # print(ppt)
# print(pptdct) # print(pptdct)
if valid(pptdct): if valid(pptdct):

+ 1
- 5
day4b.py Прегледај датотеку

pptchunks = ppt.split(" ") pptchunks = ppt.split(" ")
pptdct = {} pptdct = {}
for chunk in pptchunks: for chunk in pptchunks:
try:
if chunk != "":
bits = chunk.split(":") bits = chunk.split(":")
pptdct[bits[0]] = bits[1] pptdct[bits[0]] = bits[1]
except:
print(ppt)
# print(ppt)
# print(pptdct)
if valid(pptdct): if valid(pptdct):
count += 1 count += 1
else: else:

Loading…
Откажи
Сачувај