You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

day6b.py 544B

12345678910111213141516171819202122
  1. def checkLists(a, grp):
  2. for line in grp:
  3. if a not in line:
  4. return False
  5. return True
  6. def main():
  7. with open("input6.txt") as file:
  8. text = file.read()
  9. groups = text.split("\n\n")
  10. print(f"I have {len(groups)} groups.")
  11. count = 0
  12. for grp in groups:
  13. lgrp = grp.split("\n")
  14. sgrp = set(grp.replace("\n", ""))
  15. for letter in sgrp:
  16. if checkLists(letter, lgrp):
  17. count += 1
  18. print(f"The total is {count}.")
  19. if __name__ == "__main__":
  20. main()