Update 2023 solvers according to template change
This commit is contained in:
parent
5cd143fcb5
commit
aaf069f1a9
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 01 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day01.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day01.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,6 +2,15 @@
|
||||
"""
|
||||
Jour 02 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day02.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i.split(": ")[1] for i in sample if i != '' ]
|
||||
return sample
|
||||
|
||||
class Tirage():
|
||||
def __init__(self, tirage):
|
||||
@ -22,14 +31,6 @@ class Tirage():
|
||||
def __repr__(self):
|
||||
return f"r{self.red}g{self.green}b{self.blue}"
|
||||
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day02.txt', 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i.split(": ")[1] for i in sample if i != '' ]
|
||||
return sample
|
||||
|
||||
def parse_tirage(tirage):
|
||||
tirage.split(", ")
|
||||
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 03 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day03.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day03.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 04 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day04.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day04.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 05 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day05.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day05.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 06 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day06.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day06.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -3,11 +3,12 @@
|
||||
Jour 07 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
from functools import cmp_to_key
|
||||
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day07.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day07.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ (i.split(" ")[0], i.split(" ")[1]) for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,6 +2,15 @@
|
||||
"""
|
||||
Jour 08 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day08.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
||||
def gcd(a, b):
|
||||
while b:
|
||||
@ -17,15 +26,6 @@ def lcm_of_list(numbers):
|
||||
result = lcm(result, num)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day08.txt', 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ i for i in sample if i != '' ]
|
||||
return sample
|
||||
|
||||
def parse_sample(sample):
|
||||
instructions = sample[0]
|
||||
mappings = {
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 09 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day09.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day09.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ [int(j) for j in i.split()] for i in sample if i != '' ]
|
||||
return sample
|
||||
|
@ -2,10 +2,12 @@
|
||||
"""
|
||||
Jour 10 du défi Advent Of Code pour l'année 2023
|
||||
"""
|
||||
import os
|
||||
|
||||
def read_sample():
|
||||
"""récupère les entrées depuis le fichier texte correspondant"""
|
||||
with open('inputs/day10.txt', 'r') as f:
|
||||
filename = os.path.join(os.path.dirname(__file__ ), "inputs", "day10.txt")
|
||||
with open(filename, 'r') as f:
|
||||
sample = f.read().split('\n')
|
||||
sample = [ [j for j in i] for i in sample if i != '' ]
|
||||
return sample
|
||||
|
Loading…
Reference in New Issue
Block a user