Skip to content

Instantly share code, notes, and snippets.

View dishbreak's full-sized avatar

Vishal Kotcherlakota dishbreak

View GitHub Profile
@dishbreak
dishbreak / README.md
Created November 29, 2023 06:43
Avent of Code: The Space Hash

The Space Hash

In a lot of Advent of Code problems, you're asked to deal with 2-dimensional or 3-dimensional data sets. Some examples of this include:

  • Cellular Automata problems: problems where each element changes based on its neighbors
  • Image processing problems: problems where we need to compose an image from pixels
  • Pathfinding problems: problems where we need to find a path across a 2-dimensional map

Why Two-Dimensional Arrays Fall Apart

@dishbreak
dishbreak / cookietest.hs
Created April 11, 2024 22:37
Advent of Code 2015 Day 15 in Haskell
import Data.List
-- Is this good haskell? I've got no idea.
-- Saving this solution because I didn't do it in go.
combos = [[a, b, c, d] | a <- [1..100], b <- [1..100], c <- [1..100], d <- [1..100], a+b+c+d == 100]
ingredients = [[2, 0, -2, 0],[0, 5, -3, 0],[0, 0, 5, -1],[0, -1, 0, 5]]
matches = [zip ingredients combo | combo <- combos ]
mults = [ [ map (\y -> y * snd x) (fst x) | x <- match ] | match <- matches ]