Skip to content

Instantly share code, notes, and snippets.

@mdarrik
mdarrik / aoc-2021-day-17-math-explanation-part-1.md
Created December 18, 2021 04:42
A walkthrough of the mathematical solution to Advent of Code 2021, day 17, part 1

Getting the bounds for part 1

Some things we know about the problem:

  • We can treat x & y as mostly independent variables
  • When initial_y_velocity > 0, the velocity to reach y=0 again = -initial_y_velocity
    • We can see this in the example below, where initial_y_velocity = 2.
      1. From y=0 we move 2 points to y = 2
      2. From y = 2 we move 1 point to y = 3
  1. From y = 2 we move 0 points because velocity is 0
@mdarrik
mdarrik / toast-watcher.js
Last active October 25, 2020 20:44
a naive filewatcher for Toast & TailwindCSS
import chokidar from 'chokidar'
import {create} from 'browser-sync'
import {exec} from 'child_process'
//initialize browserSync
let browserSync = create();
// function for building the site
let build = (callback) => {
//just run the npm script directly as a child-process
@mdarrik
mdarrik / array-shorten.js
Created August 30, 2019 23:23
Shorten an Array To a Specified Length
const arrayToShorten = [0,1,2,3,4,5,6,7]
arrayToShorten
// output: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
arrayToShorten.length = 3
arrayToShorten
// output: [ 0, 1, 2 ]