🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

aocf

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aocf

Framework for working with Advent of Code in typescript

0.1.0
latest
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Advent of Code Framework (aocf)

Framework for working with Advent of Code in typescript

Usage

Can be used to structure puzzles as classes

import {AoC} from 'aocf'

export class AoC2020Day1 extends AoC {
    partA(input: string):number {
        return 95;
    }

    partB(input: string): number {
        return 105;
    }
}

// Download data using a $AOC_SESSION and run against your input
new AoC2020Day1.run()
// 2020-12-01: 0.934ms - Duration that the solution run in
// 2020-12-01.Question#1 95 // Answer to Q1
// 2020-12-01.Question#2 105 // Answer to Q2

Or used as a script format

import {AoC} from 'aocf'

const aoc = AoC.create(2020, 1)
const input = await aoc.input

Or as a combination

import {AoC} from 'aocf'

const aoc = AoC.create(2020, 1);

aoc.partA = (d) => {
  let total = 0;
  for (const line of d.split('\n')) total++;
  return total;
};

aoc.run();

Export

All answers and input can be export into a JSON file for sharing

import '@blacha/advent-of-code-2020';
const data = await AoC.export(2020);
writeFileSync(`./aoc-${data.user}-${data.year}.json`, JSON.stringify(data, null, 2));

Format:

export interface AoCJsonData {
    /** Github username for where the puzzle data came from */
    user: string;
    /** Advent of code year */ 
    year: number;

    puzzles: {
        /** Raw puzzle input */
        input: string;
        /** Answers for the day */
        answers: { a: string | number, b: string | number}
    }[]
}

Configuration

Session and data storage locations can be configured with a .aocrc or environment variables

AOC_SESSION=YourAoCSession
AOC_USER=blacha # github user name
AOC_DATA_PATH=. # Store the .aoc-data folder in the same folder as your .aocrc
export AOC_SESSION=YourAoCSession

FAQs

Package last updated on 10 Dec 2020

Did you know?

Socket

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.

Install

Related posts