Skip to content

Create script to be used by GitHub actions #2

Open
@brendanator

Description

@brendanator
  • Create advent_of_code.py script using typer
  • Commands
    • uv run advent_of_code.py download {year} {day}
    • uv run advent_of_code.py read {year} {day}
    • uv run advent_of_code.py submit {year} {day} {part}
    • uv run advent_of_code.py update-results {year}
  • uv run advent_of_code.py download {year} {day}
    • fetches https://adventofcode.com/{year}/day/{day} using httpx
    • Use the AOC_SESSION env var for cookie auth. Headers:
      • Cookie: session={AOC_SESSION}
      • User-Agent: github.com/sourcery-ai/autonomous-advent-of-code
    • uses beautifulsoup and markdownify to extract the question and convert to markdown
    • if the question contains the title "Part Two" it is part 2, otherwise part 1
    • rot13 encodes the question
    • writes files:
      • puzzles/year_2023/day_03/question_part{part}_rot13.md - include both parts in part2
      • puzzles/year_2023/day_03/input.txt
    • print to stdout 2 if part two was found else 1
  • uv run advent_of_code.py read {year} {day} {part}
    • read file puzzles/year_{year}/day_{day}/question_part{part}_rot13.md
    • rot13 decodes the puzzle
    • prints the result
  • uv run advent_of_code.py submit {year} {day} {part}
    • read file puzzles/year_{year}/day_{day}/answer_part{part}.txt
    • submits a solution to - https://adventofcode.com/{year}/day/{day}/answer using httpx and AOC_SESSION auth
    • Parses the response into markdown
    • Writes the markdown to file puzzles/year_{year}/day_{day}/result_part{part}.md
    • Prints the markdown
    • if the markdown contains "That's the right answer"
      • then return exit code 0
      • else return exit code 1
  • uv run advent_of_code.py update-results {year}
    • Calculate the results for each day in the year
      • Reads the answer and results files for each part in puzzles/year_{year}/day_{day}
        if they exist
      • Outputs the state for each day and part:
        • NOT_SUBMITTED
        • INCORRECT
        • CORRECT
    • Updates the results table in README.md
      • The results table will be contained within html comments:
      • Columns: Day, Part 1, Part 2
      • Include all day up to the latest day with results
      • For each part:
        • NOT_SUBMITTED -> blank
        • INCORRECT -> ❌
        • NOT_SUBMITTED -> ✅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions