sln_2022_13
Copyright(c) Eric Mertens 2022
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2022/day/13

>>> :{
:main +
    "[1,1,3,1,1]\n\
    \[1,1,5,1,1]\n\
    \\n\
    \[[1],[2,3,4]]\n\
    \[[1],4]\n\
    \\n\
    \[9]\n\
    \[[8,7,6]]\n\
    \\n\
    \[[4,4],4,4]\n\
    \[[4,4],4,4,4]\n\
    \\n\
    \[7,7,7,7]\n\
    \[7,7,7]\n\
    \\n\
    \[]\n\
    \[3]\n\
    \\n\
    \[[[]]]\n\
    \[[]]\n\
    \\n\
    \[1,[2,[3,[4,[5,6,7]]]],8,9]\n\
    \[1,[2,[3,[4,[5,6,0]]]],8,9]\n"
:}
13
140
Synopsis

Documentation

data T Source #

An arbitrarily nested list of lists of Int

Constructors

N Int 
L [T] 

Instances

Instances details
Read T Source # 
Instance details

Defined in Main

Show T Source # 
Instance details

Defined in Main

Methods

showsPrec :: Int -> T -> ShowS #

show :: T -> String #

showList :: [T] -> ShowS #

Eq T Source # 
Instance details

Defined in Main

Methods

(==) :: T -> T -> Bool #

(/=) :: T -> T -> Bool #

t :: ReadP T Source #

Parse a single nested lists of integer value. This parser uses a single letter name to make it accessible from the format quasiquoter.

main :: IO () Source #

>>> :main
5340
21276

compareT :: T -> T -> Ordering Source #

Compare two T values together using a lexicographic order on lists and promoting integer nodes to singleton list nodes as needed.

compareTs :: [T] -> [T] -> Ordering Source #

Lexicographic ordering of lists of T values.