Skip to content

churris-x/advent-of-code_22

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of code 2022

Solutions to each day, in the following format:

1                   # day
├── eg.txt          # example input
├── input.txt       # actual puzzle input
├── solution.js     # contains the puzzle solution
└── todo.txt        # puzzle preamble and premise

Use

  1. Run $ npm i to install dotenv.

  2. Run $ npm start, you will be prompted for your AoC session token (cookie) to fetch your puzzle inputs. You can also manually write it to the .env file with the key AUTH_TOKEN=2343223432...

  3. Run $ npm run fetch <days> to fetch the desired days, you can fetch many days at once with brace expansion, eg: $ npm run fetch {1..5} will translate to $ npm run fetch 1 2 3 4 5

  4. Run puzzles with $ node <day>/solution.js if the coresponding folder existis

NPM scripts

  • $ npm run fetch <days> or input which days you want to fetch
  • $ npm run delete <days> or input which days you want to delete, confirm with y

Todo:

  • Transfer scripts to bash scripts (run with sh)
  • Fetch and delete need to check if there is an $1 input before prompting user
  • put days in separate folder? nah
  • Maybe only allow dev to fetch and use the token, the already solved solutions should keep the input? No, in theory each input is user based
  • Make the fs.readFile api work from different working directories -> require.resolve('path/')
  • Get help in refactoring bash scripts
  • After first install ($ npm start) creates the .env file and prompt with the token prompt | cat > .env
  • Create util/ folder, move template.js and fetchInput.js to it
  • Script that creates the next puzzle folder, fetches input.txt, and creates solution.js template
  • Making requests to the aoc servers should be throttled, once every 15 minutes (900s)
  • Make newDay script also fetch todo.md, coverting to md will be a challenge, maybe html first
  • Catch auth error from fetchInput when the cookie is outdated
  • Add flag to fetch command that loops through existing day folders
  • Create util that given a async path => fs.readFile(require.resolve(path)) something like that with try catch
  • Fix bash semicolon usage, either ; or no

License

My solutions are released under the MIT License. Puzzles and inputs belong to Advent of Code