Skip to main content

Library for Advent of Code -- Hugues Hoppe.

Project description

Module advent_of_code_hhoppe

Python library to process Advent-of-Code puzzles in a Jupyter notebook. See a complete example.

Usage summary:

  • The preamble optionally specifies reference inputs and answers for the puzzles:

      BASE_URL = 'https://github.com/hhoppe/advent_of_code_2021/blob/main/data/google.Hugues_Hoppe.965276/'
      INPUT_URL = BASE_URL + '2021_{day:02}_input.txt'
      ANSWER_URL = BASE_URL + '2021_{day:02}{part_letter}_answer.txt'
      advent = advent_of_code_hhoppe.Advent(
          year=2021, input_url=INPUT_URL, answer_url=ANSWER_URL)
    
  • For each day (numbered 1..25), the first notebook cell defines a puzzle object:

      puzzle = advent.puzzle(day=1)
    

    The puzzle input string is automatically read into the attribute puzzle.input. This input string is unique to each Advent participant.

    For each of the two puzzle parts, a function (e.g. process1) takes an input string and returns a string or integer answer. Using calls like the following, we time the execution of each function and verify the answers:

      puzzle.verify(part=1, func=process1)
      puzzle.verify(part=2, func=process2)
    
  • At the end of the notebook, a table summarizes timing results.

Alternative ways to specify puzzle inputs/answers

  • The puzzle inputs and answers can be more efficiently downloaded using a single ZIP file:

      PROFILE = 'google.Hugues_Hoppe.965276'
      ZIP_URL = f'https://github.com/hhoppe/advent_of_code_2021/raw/main/data/{PROFILE}.zip'
      !if [[ ! -d {PROFILE} ]]; then wget -q {ZIP_URL} && unzip -q {PROFILE}; fi
      INPUT_URL = f'{PROFILE}/{{year}}_{{day:02d}}_input.txt'
      ANSWER_URL = f'{PROFILE}/{{year}}_{{day:02d}}{{part_letter}}_answer.txt'
      advent = advent_of_code_hhoppe.Advent(
          year=2021, input_url=INPUT_URL, answer_url=ANSWER_URL)
    
  • The puzzle inputs and answers can be obtained directly from adventofcode.com using a web-browser session cookie and the advent-of-code-data PyPI package:

      !pip install -q advent-of-code-data
      import aocd
      # Fill-in the session cookie in the following:
      mkdir -p ~/.config/aocd && echo 53616... >~/.config/aocd/token
      advent = advent_of_code_hhoppe.Advent(year=2021)
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

advent_of_code_hhoppe-1.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

advent_of_code_hhoppe-1.1.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file advent_of_code_hhoppe-1.1.2.tar.gz.

File metadata

  • Download URL: advent_of_code_hhoppe-1.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for advent_of_code_hhoppe-1.1.2.tar.gz
Algorithm Hash digest
SHA256 183370accdcba31d4771fa6dcefe038471c243be12e3e0bf74047725f566173e
MD5 d066a1ff0a02a96c924cf23afd56321a
BLAKE2b-256 c7ec3c258e54fa02be86b170f6ac609a16bcee6c986b578929c42a44d1c68a5e

See more details on using hashes here.

File details

Details for the file advent_of_code_hhoppe-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for advent_of_code_hhoppe-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a87b601584bb42e4497e943ca6c1c65583784a0eab558e786b1afcc57927d0f4
MD5 325f0b79391a1c05caa56a911b19afdd
BLAKE2b-256 696bd7f505f1e0ee59b7bcd2d840f1612f0d1837e3f0fedc1512e8c9c2731a32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page