2016: d06: ex1: add solution
This commit is contained in:
parent
328ae5cc3b
commit
b57e8e30e8
1 changed files with 24 additions and 0 deletions
24
2016/d06/ex1/ex1.py
Executable file
24
2016/d06/ex1/ex1.py
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import sys
|
||||
|
||||
|
||||
def solve(input: str) -> str:
|
||||
def error_correct(messages: list[str]) -> str:
|
||||
res: list[str] = []
|
||||
for i in range(len(messages[0])):
|
||||
res.append(collections.Counter(l[i] for l in messages).most_common()[0][0])
|
||||
return "".join(res)
|
||||
|
||||
messages = input.splitlines()
|
||||
return error_correct(messages)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = sys.stdin.read()
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue