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
# pyright: standard | |
from typing import TypeIs, reveal_type, TypeVar, Generic, Sequence, cast | |
T1 = TypeVar('T1') | |
Numeric = TypeVar('Numeric', bound=float) | |
class NonemptyTuple(tuple, Generic[T1]): | |
def __init__(self, *args, **kwargs): | |
raise ValueError("Never construct me directly") # Idk |
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
module DaySeventeen (wins, program, go, runSingleInput, workBackwards, partOne, evaluateOperand, runProgram, buildComputer, execute, Instruction(..), Operand(..), Combo(..), parsePair) where | |
import Debug.Trace | |
import Data.Bits (xor) | |
import Data.Maybe (isJust) | |
import Data.List.Split (chunksOf) | |
import qualified Data.Sequence as S | |
data Computer = Computer { instructionPointer :: Int, registerA :: Int, registerB :: Int, registerC :: Int } deriving (Ord, Eq, Show) |
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
module DayEleven (partOne, partTwo, turnStone) where | |
import qualified Data.Map as DM | |
splitDownMiddle :: Int -> [Int] | |
splitDownMiddle toSplit = [leftSide, rightSide] | |
where stringRepresentation = show toSplit | |
newSize = length stringRepresentation `div` 2 | |
leftSide = read $ take newSize stringRepresentation |
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
module DayEight (partOne, partTwo, sampleRadios, mkAntinode, difference, translate, pairs) where | |
import Data.List (groupBy, sortOn, unfoldr) | |
import Data.Array (assocs) | |
import qualified Data.Set as S | |
import Data.Ix (inRange) | |
import ArrayHelpers (listTo2dArray) | |
type Vector = (Int, Int) |
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
module DaySix (partTwo, allInterestingWorlds) where | |
import Data.Maybe (catMaybes, listToMaybe, mapMaybe) | |
import qualified Data.Set as S | |
import Control.Parallel.Strategies | |
type Location = (Int, Int) | |
data Game = Game (S.Set Obstacle) Location Int Int deriving (Show, Eq, Ord) |
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
module DayFive (partOne, partTwo) where | |
import Data.List (tails) | |
import Data.Graph | |
testRules = [(47,53), | |
(97,13), | |
(97,61), | |
(97,47), | |
(75,29), |
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
{-# LANGUAGE OverloadedStrings #-} | |
module DayFour (allPaths, wordSearch, listTo2dArray, sampleXmas, addLookahead, partTwo) where | |
import qualified Data.Text as T | |
import Data.Array | |
import Data.Set (fromList, intersection, Set) | |
import qualified Data.List.ZigZag as Z | |
import Data.List (transpose) | |
sampleXmas :: [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
{-# LANGUAGE OverloadedStrings #-} | |
module DayThree (partOne, partTwo, ParseState(Start), parseAllOps, sampleOps) where | |
import Safe (headDef) | |
import qualified Data.Maybe as M | |
import qualified Data.Text as T | |
import Data.Text (isPrefixOf) | |
import qualified Text.Read as TR | |
import Numeric (lexDigits) |
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
{-# LANGUAGE OverloadedStrings #-} | |
module DayTwo (partOne, partTwo, isSafeWithSingleModification, allVariations) where | |
import qualified Data.Set as S | |
import qualified Data.Text as T | |
import qualified Text.Read as TR | |
import Topograph (pairs) | |
readText :: T.Text -> Int |
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
{-# LANGUAGE OverloadedStrings #-} | |
module DayOne (partOne, partTwo, testLines) where | |
import qualified Text.Read as TR | |
import qualified Data.Text as T | |
import qualified Data.List as L | |
import qualified Test.LeanCheck.Stats as TS | |
import qualified Data.Map as DM |
NewerOlder