From b42c2a8852b70da7114bd73d72e239509d53f524 Mon Sep 17 00:00:00 2001 From: Vicky Date: Wed, 3 Dec 2025 06:51:45 +0000 Subject: [PATCH] Add executable file. --- vicky/dec1/dec1.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 vicky/dec1/dec1.py diff --git a/vicky/dec1/dec1.py b/vicky/dec1/dec1.py new file mode 100644 index 0000000..091b091 --- /dev/null +++ b/vicky/dec1/dec1.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Puzzle 1 of AoC 2025 +# Author: Victoria Ramírez López +# +# Date: December 1, 2025 + +# In[97]: + + +# Import instruction file +instructions = open('dummy_input.txt','r') + + +# In[98]: + + +# Calculate passcode +dial_position = 50 +passcode = 0 + +for instruction in instructions: + dial_position = rotate_dial(instruction, dial_position) + if dial_position == 0: + passcode = passcode + 1 + +print(passcode) + + +# In[89]: + + +def rotate_dial(instruction = '', dial_position=50): + # This function rotates the dial based on the input from the set of instructions + # input: instruction = String + # output: dial_position + + # Split the instruction into "direction" and "distance" + direction = instruction[0] + distance = int(instruction[1:]) + + # Calculate final position of the dial + if direction == 'R': + dial_position = (dial_position + distance) % 100 + elif direction == 'L': + dial_position = (dial_position - distance) % 100 + + return dial_position +