This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(module day1 racket | |
(provide part1 part2 get-input debugging?) | |
(require threading) | |
(define (get-input) | |
(file->string "day1.txt")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (prefix-in data: "2020_data.rkt")) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(module+ day1 | |
(define expenses (map string->number (string-split (data:day1) #:trim? #t #:repeat? #t))) | |
(define sum-is-2020? (compose (curry = 2020) (curry apply +))) | |
(define (part1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <iostream> | |
#include <chrono> | |
HHOOK mhook; | |
MSG msg; | |
bool forwardButtonHeld = false; | |
long mouseX = 0; | |
long mouseY = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
#[derive(Debug)] | |
enum Op { | |
Value(String), | |
And(String, String), | |
Or(String, String), | |
Not(String), | |
RShift(String, String), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
{-# LANGUAGE QuasiQuotes #-} | |
import Data.List.Split | |
import Data.List | |
import Text.RawString.QQ | |
main = print $ numNiceStrings1 input | |
where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Set (fromList) | |
newPos '^' (x, y) = (x, y+1) | |
newPos '<' (x, y) = (x-1, y) | |
newPos '>' (x, y) = (x+1, y) | |
newPos 'v' (x, y) = (x, y-1) | |
curPos = head . reverse | |
moveSanta acc d = acc ++ [newPos d (curPos acc)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
{-# LANGUAGE QuasiQuotes #-} | |
import Data.List.Split | |
import Text.RawString.QQ | |
main = print $ (totalPaperRequired, totalRibbonRequired) | |
where | |
boxes = splitOn "\n" input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
direction '(' = 1 | |
direction ')' = (-1) | |
direction x = 0 | |
checkBasement (-1) oldPos pos = min pos oldPos | |
checkBasement currentFloor oldPos pos = oldPos | |
stepFn (curFloor, minFloor, curPos) y = ((curFloor + direction y), (checkBasement (curFloor + direction y) minFloor curPos), curPos + 1) | |
main = print $ foldl stepFn (0, 7000, 1) "((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()()(()(((()(((((())()))()((()(()))()((()((((())((((())(()(((())()()(()()()()()(())((((())((())(()()))()((((())))((((()())()((((())((()())((())(())(((((()((((()(((()((((())(()(((()()))()))((((((()((())()())))(((()(()))(()()(()(((()(()))((()()()())((()()()(((())())()())())())((()))(()(()))(((((()(()(())((()(())(())()((((()())()))((((())(())((())())((((()(((())(())((()()((((()((((((()(() |