diff --git a/.github/README.md b/.github/README.md index b6f2ee8..63d4873 100644 --- a/.github/README.md +++ b/.github/README.md @@ -4,23 +4,39 @@ Solutions to the [2020 Advent of Code](https://adventofcode.com/2020), in both P Go solutions are near direct copies of the Python solutions and may be added a few days afterwards. -**Key:** ![Completed][check] is completed, ![Incomplete][cross] is incomplete. +**Key:** ![Completed][check] is completed, ![Incomplete][cross] is incomplete, ![Partially complete][partial] is partially complete and ![Not yet attempted][pending] is released but not yet attempted. -| | Part 1 | Part 2 | | Part 1 | Part 2 | -|----|-------------------------|-------------------------|----|-------------------------|-------------------------| -| 1 | ![Completed][check] | ![Completed][check] | 2 | ![Completed][check] | ![Completed][check] | -| 3 | ![Completed][check] | ![Completed][check] | 4 | ![Completed][check] | ![Completed][check] | -| 5 | ![Completed][check] | ![Completed][check] | 6 | ![Completed][check] | ![Completed][check] | -| 7 | | | 8 | | | -| 9 | | | 10 | | | -| 11 | | | 12 | | | -| 13 | | | 14 | | | -| 15 | | | 16 | | | -| 17 | | | 18 | | | -| 19 | | | 20 | | | -| 21 | | | 22 | | | -| 23 | | | 24 | | | -| 25 | | | | | | + +| Day | | Python | Go | +|-----|---------------------|--------|----| +| 1 | ![Completed][check] | | | +| 2 | ![Completed][check] | | | +| 3 | ![Completed][check] | | | +| 4 | ![Completed][check] | | | +| 5 | ![Completed][check] | | | +| 6 | ![Not yet attempted][pending] | | | +| 7 | | | | +| 8 | | | | +| 9 | | | | +| 10 | | | | +| 11 | | | | +| 12 | | | | +| 13 | | | | +| 14 | | | | +| 15 | | | | +| 16 | | | | +| 17 | | | | +| 18 | | | | +| 19 | | | | +| 20 | | | | +| 21 | | | | +| 22 | | | | +| 23 | | | | +| 24 | | | | +| 25 | | | | + [check]: https://github.com/codemicro/adventOfCode/blob/master/.github/check.jpg?raw=true [cross]: https://github.com/codemicro/adventOfCode/blob/master/.github/cross.jpg?raw=true +[partial]: https://github.com/codemicro/adventOfCode/blob/master/.github/partial.jpg?raw=true +[pending]: https://github.com/codemicro/adventOfCode/blob/master/.github/asterisk.jpg?raw=true \ No newline at end of file diff --git a/.github/partial.jpg b/.github/partial.jpg new file mode 100644 index 0000000..d93de9c Binary files /dev/null and b/.github/partial.jpg differ diff --git a/.github/tablegen.py b/.github/tablegen.py new file mode 100644 index 0000000..9f60531 --- /dev/null +++ b/.github/tablegen.py @@ -0,0 +1,41 @@ +from datetime import datetime +import re + +today_day = datetime.now().day + +readme_text = open(".github/README.md").read().strip().split("\n") + +start_flag = "" +end_flag = "" + +table_lines = [] +in_table = False +for line in readme_text: + line = line.strip() + + if line == end_flag: + in_table = False + if in_table: + table_lines.append(line) + elif line == start_flag: + in_table = True + +for i, l in enumerate(table_lines): + rs = re.match(r"\|\s*(\d{1,})\s*\|\s*\|.+\|.+\|", l) + if rs is not None and int(rs.group(1)) == today_day: + + table_lines[i] = f"| {today_day} | ![Not yet attempted][pending] | | |" + +counter = 0 +for i, line in enumerate(readme_text): + line = line.strip() + + if line == end_flag: + in_table = False + if in_table: + readme_text[i] = table_lines[counter] + counter += 1 + elif line == start_flag: + in_table = True + +open(".github/README.md", "w").write("\n".join(readme_text)) \ No newline at end of file diff --git a/.github/workflows/updatetable.yml b/.github/workflows/updatetable.yml new file mode 100644 index 0000000..78dd901 --- /dev/null +++ b/.github/workflows/updatetable.yml @@ -0,0 +1,32 @@ +name: Update table + +on: + workflow_dispatch: + schedule: + - cron: "1 5 * 12 *" + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Run script + run: python .github/tablegen.py + + - name: Git commit and push + run: | + git config user.email 'actions@github.com' + git config user.name 'github-actions' + git add .github/README.md + git commit -m 'Update table' + git push origin HEAD:${{ github.ref }} \ No newline at end of file