Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Stuart A Kurtz
/
advent-of-code-2021
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
50fc08ae
authored
Dec 18, 2021
by
Stuart Kurtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Day 18, now with corrected comment
parent
caf11616
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
src/AOC-18a.hs
src/AOC-18b.hs
src/AOC-18a.hs
View file @
50fc08ae
...
@@ -34,9 +34,9 @@ explode sn = case iter 1 sn of
...
@@ -34,9 +34,9 @@ explode sn = case iter 1 sn of
Nothing
->
Nothing
Nothing
->
Nothing
Just
(
result
,
_
,
_
)
->
Just
result
Just
(
result
,
_
,
_
)
->
Just
result
where
where
--
the second coordinate of the result encodes whether a
--
The outer Maybe wrapper encodes if a reduction occurred, and the
--
reduction occured, and if so, what numbers might need to
--
inner Maybe wrappers encode if a number need to be added to the
--
be added to the left or right
.
--
left and/or right sides of the number being constructed
.
iter
::
Int
->
SFNumber
->
Maybe
(
SFNumber
,
Maybe
Int
,
Maybe
Int
)
iter
::
Int
->
SFNumber
->
Maybe
(
SFNumber
,
Maybe
Int
,
Maybe
Int
)
iter
_
(
Regular
_
)
=
Nothing
iter
_
(
Regular
_
)
=
Nothing
iter
5
(
Pair
(
Regular
x
)
(
Regular
y
))
=
iter
5
(
Pair
(
Regular
x
)
(
Regular
y
))
=
...
...
src/AOC-18b.hs
View file @
50fc08ae
...
@@ -35,9 +35,9 @@ explode sn = case iter 1 sn of
...
@@ -35,9 +35,9 @@ explode sn = case iter 1 sn of
Nothing
->
Nothing
Nothing
->
Nothing
Just
(
result
,
_
,
_
)
->
Just
result
Just
(
result
,
_
,
_
)
->
Just
result
where
where
--
the second coordinate of the result encodes whether a
--
The outer Maybe wrapper encodes if a reduction occurred, and the
--
reduction occured, and if so, what numbers might need to
--
inner Maybe wrappers encode if a number need to be added to the
--
be added to the left or right
.
--
left and/or right sides of the number being constructed
.
iter
::
Int
->
SFNumber
->
Maybe
(
SFNumber
,
Maybe
Int
,
Maybe
Int
)
iter
::
Int
->
SFNumber
->
Maybe
(
SFNumber
,
Maybe
Int
,
Maybe
Int
)
iter
_
(
Regular
_
)
=
Nothing
iter
_
(
Regular
_
)
=
Nothing
iter
5
(
Pair
(
Regular
x
)
(
Regular
y
))
=
iter
5
(
Pair
(
Regular
x
)
(
Regular
y
))
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment