Skip to content

Commit 75dedd0

Browse files
authored
Merge pull request github#1 from rcruz63/feature/dia1
New: dia 1 completed
2 parents 1599ba2 + e0a57b5 commit 75dedd0

11 files changed

Lines changed: 2258 additions & 0 deletions

File tree

README_DIA1_EN.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Day 1: Trebuchet?!
2+
Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems.
3+
4+
You've been doing this long enough to know that to restore snow operations, you need to check all fifty stars by December 25th.
5+
6+
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
7+
8+
You try to ask why they can't just use a weather machine ("not powerful enough") and where they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a lot of questions") and hang on did you just say the sky ("of course, where do you think snow comes from") when you realize that the Elves are already loading you into a trebuchet ("please hold still, we need to strap you in").
9+
10+
As they're making the final adjustments, they discover that their calibration document (your puzzle input) has been amended by a very young Elf who was apparently just excited to show off her art skills. Consequently, the Elves are having trouble reading the values on the document.
11+
12+
The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number.
13+
14+
For example:
15+
16+
```
17+
1abc2
18+
pqr3stu8vwx
19+
a1b2c3d4e5f
20+
treb7uchet
21+
```
22+
23+
In this example, the calibration values of these four lines are 12, 38, 15, and 77. Adding these together produces 142.
24+
25+
Consider your entire calibration document. What is the sum of all of the calibration values?
26+
27+
## Part Two
28+
Your calculation isn't quite right. It looks like some of the digits are actually spelled out with letters: one, two, three, four, five, six, seven, eight, and nine also count as valid "digits".
29+
30+
Equipped with this new information, you now need to find the real first and last digit on each line. For example:
31+
32+
two1nine
33+
eightwothree
34+
abcone2threexyz
35+
xtwone3four
36+
4nineeightseven2
37+
zoneight234
38+
7pqrstsixteen
39+
In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76. Adding these together produces 281.
40+
41+
What is the sum of all of the calibration values?
42+
43+
44+

README_DIA1_ES.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Día 1: ¿Un trebuchet?!
2+
3+
Algo está mal con la producción global de nieve, y te han seleccionado para echar un vistazo. Los Elfos incluso te han dado un mapa; en él, han utilizado estrellas para marcar las cincuenta ubicaciones principales que probablemente estén teniendo problemas.
4+
5+
Llevas suficiente tiempo haciendo esto como para saber que para restaurar las operaciones de nieve, necesitas revisar todas las cincuenta estrellas antes del 25 de diciembre.
6+
7+
Recolecta estrellas resolviendo acertijos. Dos acertijos estarán disponibles cada día en el calendario de Adviento; el segundo acertijo se desbloquea cuando completes el primero. Cada acertijo otorga una estrella. ¡Buena suerte!
8+
9+
Intentas preguntar por qué no pueden simplemente usar una máquina del tiempo ("no lo suficientemente potente") y dónde te están enviando incluso ("al cielo") y por qué tu mapa parece mayormente en blanco ("haces muchas preguntas") y espera, ¿acabas de decir el cielo? ("por supuesto, ¿de dónde crees que viene la nieve?") cuando te das cuenta de que los Elfos ya te están cargando en un trebuchet ("por favor, quédate quieto, necesitamos atarte").
10+
11+
Mientras están haciendo los ajustes finales, descubren que su documento de calibración (tu entrada para el acertijo) ha sido modificado por un Elf muy joven que aparentemente estaba emocionado por mostrar sus habilidades artísticas. En consecuencia, los Elfos tienen problemas para leer los valores en el documento.
12+
13+
El documento de calibración recientemente mejorado consiste en líneas de texto; cada línea originalmente contenía un valor de calibración específico que los Elfos ahora necesitan recuperar. En cada línea, el valor de calibración se puede encontrar combinando el primer dígito y el último dígito (en ese orden) para formar un número de dos dígitos.
14+
15+
Por ejemplo:
16+
17+
```
18+
1abc2
19+
pqr3stu8vwx
20+
a1b2c3d4e5f
21+
treb7uchet
22+
```
23+
24+
En este ejemplo, los valores de calibración de estas cuatro líneas son 12, 38, 15 y 77. Sumar estos valores produce 142.
25+
26+
Considera todo tu documento de calibración. ¿Cuál es la suma de todos los valores de calibración?
27+
28+
# Parte Dos ---
29+
Tu cálculo no está del todo correcto. Parece que algunos de los dígitos están escritos con letras: uno, dos, tres, cuatro, cinco, seis, siete, ocho y nueve también cuentan como "dígitos" válidos.
30+
31+
Equipado con esta nueva información, ahora necesitas encontrar el primer y último dígito reales en cada línea. Por ejemplo:
32+
33+
dos1nueve
34+
ocho dos tres
35+
abcuno2tresxyz
36+
xtwouno3cuatro
37+
4nueveocho siete2
38+
zonoocho234
39+
7pqrstdieciséis
40+
En este ejemplo, los valores de calibración son 29, 83, 13, 24, 42, 14 y 76. Sumándolos se obtiene 281.
41+
42+
¿Cuál es la suma de todos los valores de calibración?

adv2023/__init__.py

Whitespace-only changes.

adv2023/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from adv2023.app import run
2+
# Si nombre == "main" ejecuto app.run()
3+
4+
if __name__ == "__main__":
5+
run()

adv2023/app.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""This is the main application file for the adv2023 package. """
2+
from adv2023.dia1.dia1 import dia1_1, dia1_2
3+
4+
5+
def run():
6+
"""This is the main function for the adv2023 package. """
7+
# Use a loop to keep representing a menu until the user chooses to exit
8+
while True:
9+
# Print the menu
10+
print("Welcome to the menu")
11+
print("1. Dia 1")
12+
print("Q. Exit")
13+
14+
# Ask the user for a choice
15+
choice = input("What would you like to do? ")
16+
# If the user chooses option 1, call option1()
17+
if choice == "1":
18+
dia1_1("data1_1.txt")
19+
dia1_2("data1_2.txt")
20+
# If the user chooses Q, exit the loop
21+
elif choice.upper() == "Q":
22+
break
23+
else:
24+
print("That is not a valid option")

adv2023/dia1/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)