Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

My solutions for 'Advent of code' challanges using python

NotificationsYou must be signed in to change notification settings

Kaba8081/advent-of-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overwiew

This repository contains my sollutions in Python to a series of programming challanges calledAdvent of code.

input-grabber.py

To skip the hustle of making a new directory every time i want to move on to the next problem, I've created this simple program that automates that process and grabs the specified input file directly from AOC website.

Flags

By default the program will try to get the problem's input based on the current date, but it can also be specified by changing some of these paremeters in the console window:

  • -y or--year
    Default: current year
    specify desired year of the challange (>=2015)
  • -d or--day
    Default: current day
    specify desired day of the challange (between 1 - 25)
  • -c or--create
    Default: False
    When set toTrue creates amain.py file inside the./year/day/ directory with the following contents:
    # 'Advent of code' solution for year {YEAR} day {DAY}importosimportsysglobalDIR_PATHDIR_PATH=os.path.dirname(os.path.realpath(__file__))defget_input():input=Noneifos.path.isfile(os.path.join(DIR_PATH,"input.txt")):withopen(os.path.join(DIR_PATH,"input.txt"),"r")asfile:input=file.read().strip().splitlines()returninputelse:print("Error! Input file does not exist!")sys.exit()if__name__=="__main__":input=get_input()ifnotinput:print("Error! Input file is empty!")sys.exit()# your code goes heresys.exit()

AOC_COOKIE

Advent of code's input files are generated based on the user's id inside the browser cookies. In order to retrieve this file from the server, a variable needs to be specified in a new file called.env so that inside it should look like this:

AOC_COOKIE="..."# secret cookie id goes here

To find the value, press F12 while logged in onhttps://adventofcode.com/, go tostorage tab and copy thesession cookie value.

About

My solutions for 'Advent of code' challanges using python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp