Skip to content

gagahpangeran/advent-of-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code

GPR's solution for AoC.

Most of it are written in C++ and Python.

Problem Statement

All problems/puzzles statement can be accessed on Advent of Code Website.

How To Run

C++ Solution

Assume you already install gcc in your system.

g++ <solutionfile> -o <fileoutput>

Then run the fileoutput with sample.in or input.in as file input.

./fileoutput < <fileinput>

Example to compile and run solution of 2022 day 1:

Compile

g++ sol.cpp -o sol

Run the sample input

./sol < sample.in

Run the real problem input

./sol < input.in

Python solution

Assume you already install python in your system.

Run the solutionfile with sample.in or input.in as file input.

python <solutionfile> < <fileinput>

Example to run solution of 2022 day 4:

Run the sample input

python sol.py < sample.in

Run the real problem input

python sol.py < input.in

Script

Currently there is one script to generate solution template. You should run the script from root directory of this repo.

./scripts/generate.sh <day> <year>

The day and year arguments are optional. If you do not provide it, it will automatically using current day and year based on your local time. The script will be failed if the directory is already exists.

All the example assume your local time is 2023-12-07.

Example

./scripts/generate.sh

The output of the script will be something like below.

/home/user/gpr/advent-of-code/2023/07/ is created!

The output when the directory is exists.

/home/user/gpr/advent-of-code/2023/07/ already exist!

Example with day argument

./scripts/generate.sh 13
/home/user/gpr/advent-of-code/2023/13/ is created!

Example with day and year argument

./scripts/generate.sh 27 2022
/home/user/gpr/advent-of-code/2022/27/ is created!

Write Up

Some solutions are accompanied by write up.

I am not a good write up writer. So if you find any error or typo, or if you confuse with my explanation, please open an issue or create a pull request.

Disclaimer

Solution in this repo may not be the best or readable.