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