-
Notifications
You must be signed in to change notification settings - Fork 0
/
creditreadmes.py
23 lines (20 loc) · 1.29 KB
/
creditreadmes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys;
def updateReadmes(year, day):
for currentDay in range (1, int(day) + 1):
path = "C:\\workspace\\AdventOfCode\\" + year + "\\day" + str(currentDay) + '\\README.MD'
with (open(path) as file):
lines = file.readlines()
if lines[0].startswith("--- Day"):
lines.insert(0, "It's contents are originally written by Eric Wastl, and slightly modified with my answers.\n\n\n")
lines.insert(0, "Advent of Code is a registered trademark in the United States.\n")
lines.insert(0, "This readme is archived from https://adventofcode.com/" + year + "/day/" + str(currentDay) + " and may not be commercially redistributed.\n")
for i in range(len(lines)):
puzzleAnsStart = "Your puzzle answer was "
if lines[i].startswith(puzzleAnsStart):
lines[i] = "<details><summary>Click for the correct answer using my puzzle input.</summary>Your puzzle answer was " + lines[i][len(puzzleAnsStart):] + "</details>\n\n"
with (open(path, 'w') as file):
for item in lines:
file.write(item)
if __name__ == "__main__":
day = input("Credit readmes until what day?\t")
updateReadmes("2022", day)