1
1
# Advent-of-code-py
2
+
2
3
[ Advent of Code] [ advent_of_code_link ] helper CLI and library for python projects.
3
4
4
5
** Status & Info:**
5
6
6
- | Code style | License | Project Version |
7
- | :---: | :---: | :---: |
7
+ | Code style | License | Project Version |
8
+ | :-------------------------------------- : | :-------------------------------------------- : | :--------------------------------- ---: |
8
9
| [ ![ Code style] [ black_badge ]] [ black_link ] | [ ![ License: MIT] [ license_badge ]] [ license_link ] | [ ![ PyPI] [ project_badge ]] [ project_link ] |
9
10
10
11
## Usage
11
12
12
13
### Installation
14
+
13
15
To install advent-of-code-py run following command which installs advent-of-code-py CLI and advent_of_code_py library.
16
+
14
17
``` bash
15
18
pip install advent-of-code-py
16
19
```
17
20
18
- __ OR __
21
+ ** OR **
19
22
20
23
``` bash
21
24
poetry add advent-of-code-py
22
25
```
23
26
24
27
### Usage
28
+
25
29
Initially 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.
26
30
After collecting session cookie value you need to add those values in config using advent-of-code-py CLI
31
+
27
32
``` bash
28
33
advent-of-code-py config add < session-name> < session-value>
29
34
```
30
35
31
36
Now you can import library by using
37
+
32
38
``` python
33
39
import advent_of_code_py
34
40
```
35
41
36
42
After importing a library you can use either two decorator present which are solve and submit decorator for a function of puzzle
37
43
38
44
For example:-
45
+
39
46
``` python
40
47
@advent_of_code_py.submit (2018 ,3 ,1 ,session_list = " <session-name>" )
41
48
def puzzle_2018_3_1 (input = None ):
@@ -44,16 +51,19 @@ def puzzle_2018_3_1(input=None):
44
51
```
45
52
46
53
Now after decorating function now you can call function like regular function call
54
+
47
55
``` python
48
56
puzzle_2018_3_1()
49
57
```
58
+
50
59
After calling function ` final_output ` value will be submitted by library to Advent of Code server for 2018 year day 3
51
60
problem, then returns whether the submitted answer was correct or not. If session value is not provided then
52
61
the solution will be submitted to all session value present in config file.
53
62
54
63
You can also use advent-of-code-py builtin Initializer and runner to create appropriate CLI for problem so
55
64
problem can be run from CLI instead of modifying python file every time to run appropriate function
56
65
To set advent-of-code-py puzzle as CLI
66
+
57
67
``` python
58
68
@advent_of_code_py.advent_runner ()
59
69
def main_cli ():
@@ -64,18 +74,16 @@ def main_cli():
64
74
# add other functions ...
65
75
return initializer
66
76
```
77
+
67
78
Now you can set main_cli as entry points, and it will create CLI with the appropriate name and function which was added.
68
79
So for example to run function puzzle_2018_3_1() you have to run command as ` entry-point-name run p_3_1 ` which
69
80
will run the appropriate function as well as submit as desired if the function was decorated by submit decorator or else
70
81
prints its output if the function was decorated by solve decorator.
71
82
72
83
[ advent_of_code_link ] : https://adventofcode.com
73
-
74
84
[ black_badge ] : https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
75
85
[ black_link ] : https://github.com/ambv/black
76
-
77
86
[ license_badge ] : https://img.shields.io/github/license/iamsauravsharma/advent-of-code-py.svg?style=for-the-badge
78
87
[ license_link ] : LICENSE
79
-
80
88
[ project_badge ] : https://img.shields.io/pypi/v/advent-of-code-py?style=for-the-badge&color=blue&logo=python
81
89
[ project_link ] : https://pypi.org/project/advent-of-code-py
0 commit comments