Browse Source

Day 6

main
Noëlle 3 years ago
parent
commit
5323e958b8
2 changed files with 35 additions and 0 deletions
  1. 13
    0
      day6a.py
  2. 22
    0
      day6b.py

+ 13
- 0
day6a.py View File

@@ -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 View File

@@ -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()

Loading…
Cancel
Save