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

Main

Description

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

>>> :main + "1\n2\n-3\n3\n-2\n0\n4\n"
3
1623178306
Synopsis

Documentation

main :: IO () Source #

>>> :main
1591
14579387544492

solve :: Int -> [Int] -> IO Int Source #

data Ring Source #

Constructors

Ring 

Fields

newRing Source #

Arguments

:: Int

size

-> IO Ring 

Build a new circular ring of given size

removeRing Source #

Arguments

:: Int

node to remove from ring

-> Ring

ring

-> IO Int

index after removed node

Remove a node from the ring and return the index of the node before/after it.

insertBeforeRing Source #

Arguments

:: Int

node to insert

-> Int

node to insert before

-> Ring

ring

-> IO () 

walk Source #

Arguments

:: Int

step count (positive for forward, negative for backward)

-> Int

starting index

-> Ring

ring

-> IO Int

ending index