diff --git a/day11/example.txt b/day11/example.txt new file mode 100644 index 0000000..528f9d5 --- /dev/null +++ b/day11/example.txt @@ -0,0 +1 @@ +125 17 \ No newline at end of file diff --git a/day11/input.txt b/day11/input.txt new file mode 100644 index 0000000..ec45afc --- /dev/null +++ b/day11/input.txt @@ -0,0 +1 @@ +3279 998884 1832781 517 8 18864 28 0 \ No newline at end of file diff --git a/day11/solution.py b/day11/solution.py new file mode 100644 index 0000000..dee14bd --- /dev/null +++ b/day11/solution.py @@ -0,0 +1,25 @@ +import sys +from tqdm import tqdm + +def main(input): + input_list: list = input.split(" ") + for i in tqdm(range(25)): + new_stones = [] + for num in input_list: + if num == '0': + new_stones.extend(["1"]) + elif len(num) % 2 == 0: + half = len(num) // 2 + left_half = str(int(num[:half])) + right_half = str(int(num[half:])) + + new_stones.extend([left_half, right_half]) + else: + new_stones.extend([str(int(num)*2024)]) + input_list = new_stones + print(len(input_list)) + + +if __name__ == "__main__": + input_text = sys.stdin.read().strip() + main(input_text) diff --git a/day11/solution2.py b/day11/solution2.py new file mode 100644 index 0000000..fc56087 --- /dev/null +++ b/day11/solution2.py @@ -0,0 +1,25 @@ +import sys +from tqdm import tqdm + +def main(input): + input_list: list = input.split(" ") + for i in tqdm(range(75)): + new_stones = [] + for num in input_list: + if num == '0': + new_stones.extend(["1"]) + elif len(num) % 2 == 0: + half = len(num) // 2 + left_half = str(int(num[:half])) + right_half = str(int(num[half:])) + + new_stones.extend([left_half, right_half]) + else: + new_stones.extend([str(int(num)*2024)]) + input_list = new_stones + print(len(input_list)) + + +if __name__ == "__main__": + input_text = sys.stdin.read().strip() + main(input_text)