File tree 4 files changed +80
-0
lines changed
scala/jurisk/adventofcode/y2024
test/scala/jurisk/adventofcode/y2024
4 files changed +80
-0
lines changed Original file line number Diff line number Diff line change
1
+ noop
Original file line number Diff line number Diff line change
1
+ noop
Original file line number Diff line number Diff line change
1
+ package jurisk .adventofcode .y2024
2
+
3
+ import jurisk .utils .FileInput ._
4
+ import jurisk .utils .Parsing .StringOps
5
+
6
+ object Advent09 {
7
+ type Input = List [Command ]
8
+ type N = Long
9
+
10
+ sealed trait Command extends Product with Serializable
11
+ object Command {
12
+ case object Noop extends Command
13
+ final case class Something (
14
+ values : List [N ]
15
+ ) extends Command
16
+ final case class Other (value : String ) extends Command
17
+
18
+ def parse (s : String ): Command =
19
+ s match {
20
+ case " noop" => Noop
21
+ case s " something $rem" => Something (rem.extractLongList)
22
+ case s if s.nonEmpty => Other (s)
23
+ case _ => s.failedToParse
24
+ }
25
+ }
26
+
27
+ def parse (input : String ): Input =
28
+ input.parseLines(Command .parse)
29
+
30
+ def part1 (data : Input ): N =
31
+ 0
32
+
33
+ def part2 (data : Input ): N =
34
+ 0
35
+
36
+ def parseFile (fileName : String ): Input =
37
+ parse(readFileText(fileName))
38
+
39
+ def fileName (suffix : String ): String =
40
+ s " 2024/09 $suffix.txt "
41
+
42
+ def main (args : Array [String ]): Unit = {
43
+ val realData : Input = parseFile(fileName(" " ))
44
+
45
+ println(s " Part 1: ${part1(realData)}" )
46
+ println(s " Part 2: ${part2(realData)}" )
47
+ }
48
+ }
Original file line number Diff line number Diff line change
1
+ package jurisk .adventofcode .y2024
2
+
3
+ import Advent09 ._
4
+ import org .scalatest .freespec .AnyFreeSpec
5
+ import org .scalatest .matchers .should .Matchers ._
6
+
7
+ class Advent09Spec extends AnyFreeSpec {
8
+ private def testData = parseFile(fileName(" -test-00" ))
9
+ private def realData = parseFile(fileName(" " ))
10
+
11
+ " part 1" - {
12
+ " test" in {
13
+ part1(testData) shouldEqual 0
14
+ }
15
+
16
+ " real" in {
17
+ part1(realData) shouldEqual 0
18
+ }
19
+ }
20
+
21
+ " part 2" - {
22
+ " test" in {
23
+ part2(testData) shouldEqual 0
24
+ }
25
+
26
+ " real" in {
27
+ part2(realData) shouldEqual 0
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments