A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/matijaoe/advent-of-code below:

matijaoe/advent-of-code: ๐ŸŽ„Advent of code Bun template

๐ŸŽ„ Advent of Code Template

Download template (powered by unjs/giget)

npx giget gh:matijaoe/advent-of-code advent-of-code-2023

Ensure bun is installed:

bun -v

# if not installed, run this:
curl -fsSL https://bun.sh/install | bash

Install dependencies:

Set up a new day:

Run day solutions:

Run day solutions in dev mode (without clearing console outputs):

For automatic puzzle input retrieval, define .env file with session cookie from adventofcode.com:

Generated day structure:

import { parseLines, readInput } from 'io'

const input = await readInput('day-01')

export const part1 = () => {
  const lines = parseLines(input)
  // your code goes here
  return lines.length
}

Expected index.ts solution structure (day 1 of 2022):

import { parseGroups, readInput } from 'io'
import { desc, sum } from 'utils'

const input = await readInput('day-01')

export const part1 = () => {
  const lines = parseGroups(input, Number)
  return lines.map(sum).sort(desc).at(0)
}

export const part2 = () => {
  const lines = parseGroups(input, Number)
  const top = lines.map(sum).sort(desc).slice(0, 3)
  return sum(top)
}

bun day <day-num> output:

๐ŸŒฒ Part One: 70698 (1.11 ms)
๐ŸŽ„ Part Two: 140471 (383.5 ยตs)

โญ / โŒ


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4