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
735cbe2f
authored
Dec 06, 2021
by
Stuart Kurtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Day 6
parent
621efba9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
2 deletions
advent-of-code.cabal
data/lantern-fish.txt
src/AOC-06a.hs
src/AOC-06b.hs
test/lantern-fish.txt
advent-of-code.cabal
View file @
735cbe2f
...
...
@@ -61,10 +61,12 @@ executable aoc-05b
executable aoc-06a
import : aoc-common
main-is : AOC-06a.hs
build-depends : array
executable aoc-06b
import : aoc-common
main-is : AOC-06b.hs
build-depends : array
executable aoc-07a
import : aoc-common
...
...
data/lantern-fish.txt
0 → 100644
View file @
735cbe2f
3,4,1,2,1,2,5,1,2,1,5,4,3,2,5,1,5,1,2,2,2,3,4,5,2,5,1,3,3,1,3,4,1,5,3,2,2,1,3,2,5,1,1,4,1,4,5,1,3,1,1,5,3,1,1,4,2,2,5,1,5,5,1,5,4,1,5,3,5,1,1,4,1,2,2,1,1,1,4,2,1,3,1,1,4,5,1,1,1,1,1,5,1,1,4,1,1,1,1,2,1,4,2,1,2,4,1,3,1,2,3,2,4,1,1,5,1,1,1,2,5,5,1,1,4,1,2,2,3,5,1,4,5,4,1,3,1,4,1,4,3,2,4,3,2,4,5,1,4,5,2,1,1,1,1,1,3,1,5,1,3,1,1,2,1,4,1,3,1,5,2,4,2,1,1,1,2,1,1,4,1,1,1,1,1,5,4,1,3,3,5,3,2,5,5,2,1,5,2,4,4,1,5,2,3,1,5,3,4,1,5,1,5,3,1,1,1,4,4,5,1,1,1,3,1,4,5,1,2,3,1,3,2,3,1,3,5,4,3,1,3,4,3,1,2,1,1,3,1,1,3,1,1,4,1,2,1,2,5,1,1,3,5,3,3,3,1,1,1,1,1,5,3,3,1,1,3,4,1,1,4,1,1,2,4,4,1,1,3,1,3,2,2,1,2,5,3,3,1,1
\ No newline at end of file
src/AOC-06a.hs
View file @
735cbe2f
{-# LANGUAGE TypeApplications #-}
module
Main
where
import
Data.Array
type
Population
=
Array
Int
Int
step
::
Population
->
Population
step
a
=
array
(
0
,
8
)
[(
x
,
f
x
)
|
x
<-
[
0
..
8
]]
where
f
8
=
a
!
0
f
6
=
a
!
7
+
a
!
0
f
n
=
a
!
(
n
+
1
)
makeFish
::
[
Int
]
->
Array
Int
Int
makeFish
=
accumArray
(
+
)
0
(
0
,
8
)
.
map
(
\
x
->
(
x
,
1
))
main
::
IO
()
main
=
pure
()
main
=
do
phases
<-
makeFish
.
read
@
[
Int
]
.
(
"["
++
)
.
(
++
"]"
)
<$>
readFile
"data/lantern-fish.txt"
print
.
sum
$
iterate
step
phases
!!
80
src/AOC-06b.hs
View file @
735cbe2f
{-# LANGUAGE TypeApplications #-}
module
Main
where
import
Data.Array
type
Population
=
Array
Int
Int
step
::
Population
->
Population
step
a
=
array
(
0
,
8
)
[(
x
,
f
x
)
|
x
<-
[
0
..
8
]]
where
f
8
=
a
!
0
f
6
=
a
!
7
+
a
!
0
f
n
=
a
!
(
n
+
1
)
makeFish
::
[
Int
]
->
Array
Int
Int
makeFish
=
accumArray
(
+
)
0
(
0
,
8
)
.
map
(
\
x
->
(
x
,
1
))
main
::
IO
()
main
=
pure
()
main
=
do
phases
<-
makeFish
.
read
@
[
Int
]
.
(
"["
++
)
.
(
++
"]"
)
<$>
readFile
"data/lantern-fish.txt"
print
.
sum
$
iterate
step
phases
!!
256
test/lantern-fish.txt
0 → 100644
View file @
735cbe2f
3,4,3,1,2
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