Noëlle 3 år sedan
förälder
incheckning
5323e958b8
2 ändrade filer med 35 tillägg och 0 borttagningar
  1. 13
    0
      day6a.py
  2. 22
    0
      day6b.py

+ 13
- 0
day6a.py Visa fil

@@ -0,0 +1,13 @@
def main():
with open("input6.txt") as file:
text = file.read()
groups = text.split("\n\n")
print(f"I have {len(groups)} groups.")
count = 0
for grp in groups:
sgrp = set(grp.replace("\n", ""))
count += len(sgrp)
print(f"The total is {count}.")

if __name__ == "__main__":
main()

+ 22
- 0
day6b.py Visa fil

@@ -0,0 +1,22 @@
def checkLists(a, grp):
for line in grp:
if a not in line:
return False
return True

def main():
with open("input6.txt") as file:
text = file.read()
groups = text.split("\n\n")
print(f"I have {len(groups)} groups.")
count = 0
for grp in groups:
lgrp = grp.split("\n")
sgrp = set(grp.replace("\n", ""))
for letter in sgrp:
if checkLists(letter, lgrp):
count += 1
print(f"The total is {count}.")

if __name__ == "__main__":
main()

Laddar…
Avbryt
Spara