Skip to content

Instantly share code, notes, and snippets.

@ntreu14
ntreu14 / AoC2019Day5Part1.py
Created December 6, 2019 20:31
Solution for Advent of Code 2019 Day 5 Part 1
from collections import deque
from abc import abstractmethod
puzzle_input = deque([3,225,1,225,6,6,1100,1,238,225,104,0,1002,114,19,224,1001,224,-646,224,4,224,102,8,223,223,1001,224,7,224,1,223,224,223,1101,40,62,225,1101,60,38,225,1101,30,29,225,2,195,148,224,1001,224,-40,224,4,224,1002,223,8,223,101,2,224,224,1,224,223,223,1001,143,40,224,101,-125,224,224,4,224,1002,223,8,223,1001,224,3,224,1,224,223,223,101,29,139,224,1001,224,-99,224,4,224,1002,223,8,223,1001,224,2,224,1,224,223,223,1101,14,34,225,102,57,39,224,101,-3420,224,224,4,224,102,8,223,223,1001,224,7,224,1,223,224,223,1101,70,40,225,1102,85,69,225,1102,94,5,225,1,36,43,224,101,-92,224,224,4,224,1002,223,8,223,101,1,224,224,1,224,223,223,1102,94,24,224,1001,224,-2256,224,4,224,102,8,223,223,1001,224,1,224,1,223,224,223,1102,8,13,225,1101,36,65,224,1001,224,-101,224,4,224,102,8,223,223,101,3,224,224,1,223,224,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1
@ntreu14
ntreu14 / AoC2019Day4Part2.hs
Last active December 4, 2019 06:25
Solution for Advent of Code 2019 Day 4 Part 2
module Day4Part2 where
import Data.List (group)
import Data.Monoid
lowerRange :: Int
lowerRange = 347312
upperRange :: Int
upperRange = 805915
@ntreu14
ntreu14 / AoC2019Day4Part1.hs
Last active December 4, 2019 06:26
Solution for Advent of Code 2019 Day 4 Part 1
module Day4Part1 where
import Data.Monoid
lowerRange :: Int
lowerRange = 347312
upperRange :: Int
upperRange = 805915
@ntreu14
ntreu14 / AoC2019Day3Part2.hs
Created December 3, 2019 23:09
Solution for Advent of Code 2019 Day 3 Part 2
module Day3Part2 where
import qualified Data.List as L
import qualified Data.Map.Strict as M
type Point = (Int, Int)
data Direction
= Up
| Down
@ntreu14
ntreu14 / AoC2019Day3Part1.hs
Created December 3, 2019 23:07
Solution for Advent of Code 2019 Day 3 Part 1
module Day3Part1 where
import qualified Data.List as L
import qualified Data.Set as S
type Point = (Int, Int)
data Direction
= Up
| Down
@ntreu14
ntreu14 / AoC2019Day2Part2.py
Created December 2, 2019 15:45
Solution for Advent of Code 2019 Day 2 Part 2
from collections import deque
from copy import deepcopy
puzzle_input = deque([1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,10,1,19,1,19,9,23,1,23,6,27,2,27,13,31,1,10,31,35,1,10,35,39,2,39,6,43,1,43,5,47,2,10,47,51,1,5,51,55,1,55,13,59,1,59,9,63,2,9,63,67,1,6,67,71,1,71,13,75,1,75,10,79,1,5,79,83,1,10,83,87,1,5,87,91,1,91,9,95,2,13,95,99,1,5,99,103,2,103,9,107,1,5,107,111,2,111,9,115,1,115,6,119,2,13,119,123,1,123,5,127,1,127,9,131,1,131,10,135,1,13,135,139,2,9,139,143,1,5,143,147,1,13,147,151,1,151,2,155,1,10,155,0,99,2,14,0,0])
def storeInRegister(amount, register, p):
p[register] = amount
def solvePart1(problem_input, noun, verb):
rotation_amount = 0
@ntreu14
ntreu14 / AoC2019Day2Part1.py
Created December 2, 2019 15:45
Solution for Advent of Code 2019 Day 2 Part 1
from collections import deque
puzzle_input = deque([1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,10,1,19,1,19,9,23,1,23,6,27,2,27,13,31,1,10,31,35,1,10,35,39,2,39,6,43,1,43,5,47,2,10,47,51,1,5,51,55,1,55,13,59,1,59,9,63,2,9,63,67,1,6,67,71,1,71,13,75,1,75,10,79,1,5,79,83,1,10,83,87,1,5,87,91,1,91,9,95,2,13,95,99,1,5,99,103,2,103,9,107,1,5,107,111,2,111,9,115,1,115,6,119,2,13,119,123,1,123,5,127,1,127,9,131,1,131,10,135,1,13,135,139,2,9,139,143,1,5,143,147,1,13,147,151,1,151,2,155,1,10,155,0,99,2,14,0,0])
def storeInRegister(amount, register, problem_input):
problem_input[register] = amount
def solve(problem_input):
rotation_amount = 0
while problem_input[0] <> 99:
@ntreu14
ntreu14 / AoC2019Day1Part2.hs
Last active December 1, 2019 05:54
Solution for Advent of Code 2019 Day 1 Part 2
module Day1Part2 where
input =
[
128270
, 147113
, 61335
, 78766
, 119452
, 116991
@ntreu14
ntreu14 / AoC2019Day1Part1.hs
Last active December 1, 2019 05:54
Solution for Advent of Code 2019 Day 1 Part 1
module Day1Part1 where
input =
[
128270
, 147113
, 61335
, 78766
, 119452
, 116991
@ntreu14
ntreu14 / AoC2017Day17Part2.py
Last active November 29, 2019 17:47
Solution for Advent of Code 2017 Day 17 Part 2
from collections import deque
def solve(puzzleInput, lastIterationValue):
circularBuffer = deque([])
for i in range(0, lastIterationValue + 1):
circularBuffer.rotate(puzzleInput)
circularBuffer.appendleft(i)
while circularBuffer[0] <> 0: