From 511e8abb0a5676502beaefbacebb5367c116d9a8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 9 May 2025 16:11:23 +0100 Subject: [PATCH] 2017: d04: ex1: add solution --- 2017/d04/ex1/ex1.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 2017/d04/ex1/ex1.py diff --git a/2017/d04/ex1/ex1.py b/2017/d04/ex1/ex1.py new file mode 100755 index 0000000..3904182 --- /dev/null +++ b/2017/d04/ex1/ex1.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import sys + + +def solve(input: str) -> int: + def parse(input: str) -> list[list[str]]: + return [line.split() for line in input.splitlines()] + + def validate_passphrase(passphrase: list[str]) -> bool: + return len(set(passphrase)) == len(passphrase) + + passphrases = parse(input) + return sum(map(validate_passphrase, passphrases)) + + +def main() -> None: + input = sys.stdin.read() + print(solve(input)) + + +if __name__ == "__main__": + main()