๐ŸŽ„ Advent of Code command-line tool.

Overview

๐ŸŽ„ advent-cli

advent-cli is a command-line tool for interacting with Advent of Code, specifically geared toward writing solutions in Python. It can be used to view puzzle prompts, download input, submit solutions, and view personal or private stats and leaderboards.

Installation

Clone this repository and simply run:

pip install .

(PyPI installation coming soon)

Configuration

Before you do anything, you'll need to provide advent-cli with a session cookie so it can authenticate as you. To do this, log in to the Advent of Code website and grab the cookie named session from your browser's inspect element tool. Store it in an environment variable on your machine named ADVENT_SESSION_COOKIE. A fresh session cookie is good for about a month, after which you'll need to repeat these steps.

Full list of configuration environment variables:

Variable Function
ADVENT_SESSION_COOKIE Advent of Code session cookie for authentication.
ADVENT_PRIV_BOARDS Comma-separated list of private leaderboard IDs. (optional)
ADVENT_DISABLE_TERMCOLOR Set to 1 to permanently disable coloring terminal output. (optional)

Usage

advent-cli can be invoked using the advent command, or python -m advent_cli.

Download a question

$ advent get YYYY/DD

This will create the directory YYYY/DD (e.g. 2021/01) inside the current working directory. Inside, you'll find part 1 of the puzzle prompt in prompt.md, your puzzle input in input.txt, and a generated solution template in solution.py. More about that here.

Test a solution

$ advent test YYYY/DD

This will run the solution file in the directory YYYY/DD and print the output without actually submitting. Use this to debug or check for correctness. Optional flags:

  • -e, --example: Test the solution using example_input.txt. This is an empty file that gets created when you run advent get where you can manually store the example input from the puzzle prompt. Useful for checking solutions for correctness before submitting.
  • -f, --solution-file: Test a solution file other than solution.py (e.g. -f solution2 to run solution2.py). This will assume you already have a working solution in solution.py and check the new file's output against it. Useful for testing alternate solutions after you've already submitted since you cannot re-submit.

Submit answers

$ advent submit YYYY/DD

This will run the solution file in the directory YYYY/DD and automatically attempt to submit the computed answers for that day. After implementing part 1, run this command to submit part 1 and (if correct) append the prompt for part 2 to prompt.md. Run again after implementing part 2 to submit part 2. Optional flags:

  • -f, --solution-file: Submit using a solution file other than solution.py (e.g. -f solution2 to run solution2.py). This can only be done if a correct answer hasn't already been submitted.

Check personal stats

$ advent stats YYYY

This will print out your progress for the year YYYY and output the table found on adventofcode.com/{YYYY}/leaderboard/self with your time, rank, and score for each day and part.

Check private leaderboards

$ advent stats YYYY --private

This will print out each of the private leaderboards given in ADVENT_PRIV_BOARDS. Also works with -p.

Solution structure

advent-cli expects the following directory structure (example):

2020/
 โ””โ”€ 01/
     โ””โ”€ example_input.txt
     โ””โ”€ input.txt
     โ””โ”€ prompt.md
     โ””โ”€ solution.py
     โ””โ”€ [alternate solution files]
 โ””โ”€ 02/
     โ””โ”€ ...
 โ””โ”€ ...
2021/
 โ””โ”€ 01/
     โ””โ”€ ...
 โ””โ”€ ...

The solution.py file will look like this when first generated:

## advent of code {year}
## https://adventofcode.com/{year}
## day {day}

def parse_input(lines):
    pass

def part1(data):
    pass

def part2(data):
    pass

When the solution is run, the input will be read from input.txt and automatically passed to parse_input as lines, an array of strings where each string is a line from the input with newline characters removed. You should implement parse_input to return your parsed input or inputs, which will then be passed to part1 and part2. If parse_input returns a tuple, part1 and part2 will be expecting multiple parameters that map to those returned values. The parameter names can be changed to your liking. The only constraint is that part1 and part2 must have the same number of parameters.

If part2 is left unmodified or otherwise returns None, it will be considered unsolved and part1 will be run and submitted. If both functions are implemented, part2 will be submitted.

Credits

This started out as a simple script which was inspired by Hazel and haskal.

License

advent-cli is distributed under the GNU GPL-3.0 License.

You might also like...
PyArmor is a command line tool used to obfuscate python scripts

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

A command line tool to remove background from video and image
A command line tool to remove background from video and image

A command line tool to remove background from video and image, brought to you by BackgroundRemover.app which is an app made by nadermx powered by this tool

Amazon Scraper: A command-line tool for scraping Amazon product data
Amazon Scraper: A command-line tool for scraping Amazon product data

Amazon Product Scraper: 2021 Description A command-line tool for scraping Amazon product data to CSV or JSON format(s). Requirements Python 3 pip3 Ins

A command line tool (and Python library) for archiving Twitter JSON

A command line tool (and Python library) for archiving Twitter JSON

command line tool for frequent nmigen tasks (generate sources, show design)
command line tool for frequent nmigen tasks (generate sources, show design)

nmigen-tool command line tool for frequent nmigen tasks (generate sources, show design) Usage: generate verilog: nmigen generate verilog nmigen_librar

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

googler is a power tool to Google (web, news, videos and site search) from the command-line.
googler is a power tool to Google (web, news, videos and site search) from the command-line.

googler is a power tool to Google (web, news, videos and site search) from the command-line.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.
LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

Command line tool for google dorks

CLI for google dorks This is the command line tool made with pytohn which allows the users to perform Google dorks easily Installation Install google

Comments
  • `parse_input` does not currently support Generators

    `parse_input` does not currently support Generators

    It is quite common to use generators to handle input parsing:

    def parse_input(lines: list[str]):
        for line in lines:
           yield re.match('...', line).groups()
    

    Currently, this does not work as the runner passes the same generator into Part 1 and Part 2, which is exhausted in Part 2 as it has already been iterated in Part 1.

    This can be implemented relatively easily if desired by detecting a Generator with isinstance and making a copy for Part 2.

    enhancement 
    opened by ionite34 3
  • Please read: AoC 2022 - Contributing

    Please read: AoC 2022 - Contributing

    advent-cli users,

    I haven't had much time this year to maintain this tool or make updates that I've been wanting to make, and that will likely be the case for the remainder of the year. I'm still around though, and I want this project to keep going - so if something has broken or there's a feature you really want added for this year's comp, feel free to submit a pull request and I'll gladly look over it.

    Happy coding and happy holidays!

    opened by fergusch 0
Releases(v0.2.2)
  • v0.2.2(Feb 3, 2022)

  • v0.2.1(Dec 24, 2021)

    Changes

    Features

    • Added conversion of inline <em> tags
    • Added error messages if session cookie is invalid or expired
    • countdown now returns a non-zero exit code if aborted, preventing any get commands chained with && from running

    Full changelog

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Dec 17, 2021)

    Changes

    Features

    • Added countdown command
    • Added config options for converting <em> tags to markdown
    • Private leaderboards owned by the user are now supported
    • stats command now defaults to the current year if not specified

    Bug fixes

    • Fixed a layout issue when displaying private leaderboards

    Full changelog

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Dec 11, 2021)

    Changes

    Features

    • advent-cli is now on PyPI! ๐ŸŽ‰
    • Improved error handling

    Bug fixes

    • Fixed an issue where --version would output __main__ instead of advent-cli when run with python -m
    • Fixed an issue where submit would overwrite part 1 in prompt.md after downloading part 2
    • Fixed an issue where pip would not install requirements due to a typo in setup.cfg
    • Fixed an issue where get would not create directories

    Other

    • Lowered minimum Python version to 3.7
    • Added unit tests

    Full changelog

    Source code(tar.gz)
    Source code(zip)
Owner
Christian Ferguson
i'm the cat
Christian Ferguson
Squirrel - A cli program to track writing progress

Squirrel Very much a WIP project squirrel is a command line program that tracks you writing progress and gives you useful information and cute and pic

3 Mar 23, 2022
A minimal todo list for your terminal.

todo A minimal todo list for your terminal. Installation Run the following command. pip install git+https://github.com/piero-vic/todo.git Usage todo

Piero Lescano 7 Aug 08, 2022
ctree - command line christmas tree

ctree ctree - command line christmas tree It is small python script that prints a christmas tree in terminal. It is colourful and always gives you a d

15 Aug 15, 2022
้›ป้€šๅคงใฎCLIใƒ„ใƒผใƒซใงใ™

uecli ้›ป้€šๅคงใฎCLIใƒ„ใƒผใƒซใงใ™ใ€‚ใ‚ณใƒžใƒณใƒ‰ใƒฉใ‚คใƒณใ‹ใ‚‰ใ‚ทใƒฉใƒใ‚นๆคœ็ดขใ€ๆˆ็ธพๅ‚็…งใ€ๅ›ณๆ›ธ้คจใฎ่ฒธๅ‡บใƒชใ‚นใƒˆใชใฉใ‚’่ฆ‹ใ‚‹ใ“ใจใŒใงใใพใ™ ใ‚คใƒณใ‚นใƒˆใƒผใƒซ pip install uecli ไฝฟใ„ๆ–น ใ‚ทใƒฉใƒใ‚นใ‚’ๆคœ็ดข uecli syllabus search -s 'ใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใ‚ตใ‚คใ‚จใƒณใ‚น' ใ‚ทใƒฉใƒใ‚นใ‚’ๅ–ๅพ—ใ—ใ€Mar

UEC World Dominators 2 Oct 31, 2021
Run an FFmpeg command and see the percentage progress and ETA.

Run an FFmpeg command and see the percentage progress and ETA.

25 Dec 22, 2022
Gitfetch is a simple tool to get github user details

Gitfetch Just a (cli?) tool to get github user details ๐Ÿ™‚ Installation ๐Ÿ“‚ Install Gitfetch via pypi pip install gitfetch or pip install git+https://g

I'm Not A Bot #Left_TG 7 Jan 23, 2022
A simple discord slash command handler for for discord.py.

A simple discord slash command handler for discord.py About โฆฟ Installation โฆฟ Disclaimer โฆฟ Examples โฆฟ Documentation โฆฟ Discussions Note that master bran

641 Jan 03, 2023
Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

haxor-news Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..." Coworker who sees me s

Donne Martin 3.8k Jan 07, 2023
(BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming.

blush ๐Ÿ˜ณ (BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming. Note: The Linux executables were made on Ubu

3 Jun 30, 2021
A Reverse Shell Python Packages

A Reverse Shell Python Packages

1 Nov 03, 2021
Termtyper is a TUI typing application that provides you a great feel with typing with a lot of options to tweak

Termtyper Termtyper is a TUI (Text User Interface) typing application that provides you a great feel with typing with a lot of options to tweak! It is

Noob Coder 834 Dec 27, 2022
Todo - You could use terminal to set your todo

Python Tutorial You can learn how to build a terminal application(CLI applicatio

29 Jun 29, 2022
๐Ÿƒ Python3 Solutions of All Problems in GCJ 2022 (In Progress)

GoogleCodeJam 2022 Python3 solutions of Google Code Jam 2022. Solution begins with * means it will get TLE in the largest data set. Total computation

kamyu 12 Dec 20, 2022
A user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN).

pyFmask What is pyFmask pyFmask is a user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN; https://github.com/GERSL/Fmask). Fmask (Zhu et

1 Jan 05, 2022
A CLI messenger for the Signum community.

A CLI messenger for the Signum community. Built for people who like using terminal for their work and want to communicate with other users in the Signum community.

Jush 5 Mar 18, 2022
dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

Brent Yi 119 Jan 09, 2023
A simple CLI tool for converting logs from Poker Now games to other formats

๐Ÿ‚ก Poker Now Log Converter ๐Ÿ‚ก A command line utility for converting logs from Poker Now games to other formats. Introduction Poker Now is a free onlin

6 Dec 23, 2022
Gamestonk Terminal is an awesome stock and crypto market terminal

Gamestonk Terminal is an awesome stock and crypto market terminal. A FOSS alternative to Bloomberg Terminal.

Gamestonk Terminal 18.6k Jan 03, 2023
This is the public repo for the VS Code Extension AT&T i386/IA32 UIUC-ECE391 Syntax Highlighting

AT&T i386 IA32 UIUC ECE391 GCC Highlighter & Snippet & Linter This is the VS Code Extension for UIUC ECE 391, MIT 6.828, and all other AT&T-based i386

Jackgetup 1 Feb 05, 2022
Animefetch is an anime command-line system information tool written in python

Animefetch - v0.0.3 An anime command-line system information tool written in python. Description Animefetch is an anime command-line system informatio

Thadeuks 6 Jun 17, 2022