
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@thefotios/advent_puzzle
Advanced tools
Simple helper class for parsing and running Advent of Code puzzles.
This will parse the data file in a few ways then call your processing function.
Since each day has 2 puzzles (referred to here as A and B for simplicity), you can specify separate runners for each type.
const Puzzle = require('@thefotios/advent_puzzle');
const p = new Puzzle({
// Each line is comma separated (with spaces)
delimiter: /,\s+/,
// Parse each element as an Integer
numeric: true,
});
Valid Processors are run in the following order:
| Key | When it's run |
|---|---|
| before | After parsing the data, but before each puzzle |
| A or B | Run depending on which puzzle is passed in the args |
| after | After the A or B processor is run |
| logger | Last, by default will console.log data |
// Add elements of each line
p.A = lines => lines.map(data => data.reduce((acc, x) => acc + x, 0));
// Multiply elements of each line
p.B = lines => lines.map(data => data.reduce((acc, x) => acc * x, 1));
// Sort the results of each line (descending)
p.after = data => data.sort((a, b) => b - a);
run functionBy default, this will run console.log on your final data
p.run()
node your_script.js [data_file] [A or B]
FAQs
Helper class for parsing and running Advent of Code puzzles
We found that @thefotios/advent_puzzle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.