Skip to main content

Advent of Code Colab Template Generator

A simple template generator for Advent of Code solutions in Google Colab. This package provides an easy way to set up your Advent of Code environment in Colab notebooks with just a few commands.

Features

  • One-command template generation for AOC solutions
  • Automatic AOC session management
  • Easy data fetching for any day/year
  • Colab-specific optimizations

Installation

pip install aoc-colab-template

Quick Start

from aoc_colab_template import create_template
create_template()  # Creates template with all necessary imports and setup

Usage Guide

Setting Up Your Environment

The template generator creates a cell with all necessary imports and setup:

# This code is automatically generated by create_template()
from google.colab import userdata
import os
from aocd import get_data

# Sets up your AOC session automatically
AOC_SESSION = userdata.get('AOC_SESSION')
os.environ['AOC_SESSION'] = AOC_SESSION

Getting Puzzle Input

Basic Usage

# Get data for current day (defaults to day=1, year=2023)
data = get_aocd_data()

# Get data for specific day
day5_data = get_aocd_data(day=5)

# Get data from previous year
old_data = get_aocd_data(day=1, year=2022)

Working with Input Data

# Print first few lines
print(data.split('\n')[:5])

# Common data processing patterns
lines = data.splitlines()  # Split into lines
numbers = [int(x) for x in lines]  # Convert to integers
grid = [list(line) for line in lines]  # Create 2D grid

Best Practices

  1. Session Management

    • Store your AOC session token in Colab's userdata
    • The template handles the environment setup automatically
  2. Data Fetching

    • Use get_aocd_data() instead of copy-pasting inputs
    • Specify day and year explicitly for clarity
    • Cache data when working on solutions
  3. Template Usage

    • Run create_template() at the start of each new solution notebook
    • The template includes commonly needed imports
    • Form interface makes it easy to control package installation

Error Handling

Common Issues

  1. "AOC_SESSION not found":

    • Make sure you've stored your session token in Colab's userdata
    • Check that the template setup ran successfully
  2. "Not running in Colab":

    • This package only works in Google Colab environment
    • Check you're not running in a regular Jupyter notebook

Troubleshooting

If you encounter issues:

  1. Verify you're in a Colab environment
  2. Check your AOC session token is valid
  3. Ensure you have internet connectivity
  4. Try rerunning the template generation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use this in your AOC solutions!

About Advent of Code

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Metadata

Release files for aoc-colab-template 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aoc-colab-template 0.1.9
File Size Uploaded
aoc_colab_template-0.1.9.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aoc-colab-template 0.1.9
File Interpreter ABI Platform
aoc_colab_template-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / aoc_colab_template-0.1.9.tar.gz

Download URL aoc_colab_template-0.1.9.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
18b4e1a9db7c55e60fe0c5ab146f95cb41f8d1edc8295bbe45650b9fa9ea41fc
BLAKE2b-256 checksum
How to use checksums
c0a7317da4ddd28854aaa134e4c83ca6ba85bd763fe51286849e8d5660a259ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.1

Release files / aoc_colab_template-0.1.9-py3-none-any.whl

Download URL aoc_colab_template-0.1.9-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ef238307906f486c0dc6dd4e2dcd1df77ef48d4b14397065ef7ab2a33cb5b4
BLAKE2b-256 checksum
How to use checksums
5c5b102f89349730ee90494e108a9cf800d93587bf1a7281442ca00a8e61ad6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page