Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Gehrke
aoc-2020
Commits
a9375c1b
Commit
a9375c1b
authored
Dec 05, 2020
by
Alexander Gehrke
Browse files
Use inputs lib from 2015 solution
parent
b92048c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/inputs.scala
View file @
a9375c1b
...
...
@@ -5,7 +5,19 @@ case class Location(inputDir: String, day: Int)
def
inputLines
(
using
l
:
Location
)
=
scala
.
io
.
Source
.
fromFile
(
s
"${l.inputDir}/day${l.day}.txt"
).
getLines
def
simpleInput
(
solver
:
String
=>
String
)(
using
l
:
Location
)
:
String
=
solver
(
inputLines
.
mkString
)
def
input
[
A
](
format
:
String
=>
A
=
identity
)(
solver
:
List
[
A
]
=>
String
)(
using
l
:
Location
)
:
String
=
solver
(
inputLines
.
map
(
format
).
toList
)
inputF
(
format
)(
List
)(
solver
)
def
inputF
[
A
,
C
[
_
]](
format
:
String
=>
A
=
identity
)(
coll
:
collection.Factory
[
A
,
C
[
A
]])(
solver
:
C
[
A
]
=>
String
)(
using
l
:
Location
)
:
String
=
solver
(
inputLines
.
map
(
format
).
to
(
coll
))
def
flatInput
[
A
](
format
:
String
=>
List
[
A
]
=
List
.
apply
)(
solver
:
List
[
A
]
=>
String
)(
using
l
:
Location
)
:
String
=
flatInputF
(
format
)(
List
)(
solver
)
def
flatInputF
[
A
,
C
[
_
]](
format
:
String
=>
IterableOnce
[
A
]
=
identity
)(
coll
:
collection.Factory
[
A
,
C
[
A
]])(
solver
:
C
[
A
]
=>
String
)(
using
l
:
Location
)
:
String
=
solver
(
inputLines
.
flatMap
(
format
).
to
(
coll
))
def
boolChar
(
trueChar
:
Char
)
:
String
=>
Vector
[
Boolean
]
=
_
.
map
(
_
==
trueChar
).
toVector
Write
Preview
Supports
Markdown
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