11# Advent-of-code-py
2+
23[ Advent of Code] [ advent_of_code_link ] helper CLI and library for python projects.
34
45** Status & Info:**
56
6- | Code style | License | Project Version |
7- | :---: | :---: | :---: |
7+ | Code style | License | Project Version |
8+ | :-------------------------------------- : | :-------------------------------------------- : | :--------------------------------- ---: |
89| [ ![ Code style] [ black_badge ]] [ black_link ] | [ ![ License: MIT] [ license_badge ]] [ license_link ] | [ ![ PyPI] [ project_badge ]] [ project_link ] |
910
1011## Usage
1112
1213### Installation
14+
1315To install advent-of-code-py run following command which installs advent-of-code-py CLI and advent_of_code_py library.
16+
1417``` bash
1518pip install advent-of-code-py
1619```
1720
18- __ OR __
21+ ** OR **
1922
2023``` bash
2124poetry add advent-of-code-py
2225```
2326
2427### Usage
28+
2529Initially for advent-of-code-py to work it need session value or session ID which you can obtain by viewing cookie while visiting advent of code server.
2630After collecting session cookie value you need to add those values in config using advent-of-code-py CLI
31+
2732``` bash
2833advent-of-code-py config add < session-name> < session-value>
2934```
3035
3136Now you can import library by using
37+
3238``` python
3339import advent_of_code_py
3440```
3541
3642After importing a library you can use either two decorator present which are solve and submit decorator for a function of puzzle
3743
3844For example:-
45+
3946``` python
4047@advent_of_code_py.submit (2018 ,3 ,1 ,session_list = " <session-name>" )
4148def puzzle_2018_3_1 (input = None ):
@@ -44,16 +51,19 @@ def puzzle_2018_3_1(input=None):
4451```
4552
4653Now after decorating function now you can call function like regular function call
54+
4755``` python
4856puzzle_2018_3_1()
4957```
58+
5059After calling function ` final_output ` value will be submitted by library to Advent of Code server for 2018 year day 3
5160problem, then returns whether the submitted answer was correct or not. If session value is not provided then
5261the solution will be submitted to all session value present in config file.
5362
5463You can also use advent-of-code-py builtin Initializer and runner to create appropriate CLI for problem so
5564problem can be run from CLI instead of modifying python file every time to run appropriate function
5665To set advent-of-code-py puzzle as CLI
66+
5767``` python
5868@advent_of_code_py.advent_runner ()
5969def main_cli ():
@@ -64,18 +74,16 @@ def main_cli():
6474 # add other functions ...
6575 return initializer
6676```
77+
6778Now you can set main_cli as entry points, and it will create CLI with the appropriate name and function which was added.
6879So for example to run function puzzle_2018_3_1() you have to run command as ` entry-point-name run p_3_1 ` which
6980will run the appropriate function as well as submit as desired if the function was decorated by submit decorator or else
7081prints its output if the function was decorated by solve decorator.
7182
7283[ advent_of_code_link ] : https://adventofcode.com
73-
7484[ black_badge ] : https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
7585[ black_link ] : https://github.com/ambv/black
76-
7786[ license_badge ] : https://img.shields.io/github/license/iamsauravsharma/advent-of-code-py.svg?style=for-the-badge
7887[ license_link ] : LICENSE
79-
8088[ project_badge ] : https://img.shields.io/pypi/v/advent-of-code-py?style=for-the-badge&color=blue&logo=python
8189[ project_link ] : https://pypi.org/project/advent-of-code-py
0 commit comments