From 838f0dfd931fba890ad12a260af9d6105f67a6ca Mon Sep 17 00:00:00 2001 From: augustin64 Date: Wed, 1 Dec 2021 15:29:21 +0100 Subject: [PATCH] Add utils --- utils/new_day.sh | 12 ++++++++++++ utils/template.py | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 utils/new_day.sh create mode 100755 utils/template.py diff --git a/utils/new_day.sh b/utils/new_day.sh new file mode 100755 index 0000000..b52984e --- /dev/null +++ b/utils/new_day.sh @@ -0,0 +1,12 @@ +if [[ ! -e .git ]]; then + echo "Merci de se déplacer dans le répertoire approprié" + exit 0 +fi; + +YEAR=$(date +%Y) +DAY=$(date +%d) +FILENAME="${YEAR}/day${DAY}.py" + +cp utils/template.py "$FILENAME" +sed -i "s/DAY/${DAY}/" "$FILENAME" +sed -i "s/YEAR/${YEAR}/" "$FILENAME" diff --git a/utils/template.py b/utils/template.py new file mode 100755 index 0000000..33b9dad --- /dev/null +++ b/utils/template.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +""" +Jour DAY du défi Advent Of Code pour l'année YEAR +""" + +def read_sample(): + """récupère les entrées depuis le fichier texte correspondant""" + with open('inputs/dayDAY.txt', 'r') as f: + sample = f.read().split('\n') + sample = [int(i) for i in sample if i != ''] + return sample + +def part1(sample): + """Partie 1 du défi""" + return NotImplementedError + +def part2(sample): + """Partie 2 du défi""" + return NotImplementedError + + +def main(): + """Fonction principale""" + sample = read_sample() + print(f"part1: {part1(sample)}") + print(f"part2: {part2(sample)}")