Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jurisk committed Dec 3, 2023
1 parent 3e9617b commit f1ec3d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions scala2/src/main/scala/jurisk/adventofcode/Advent00.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ object Advent00 {
final case class Something(
values: List[Int]
) extends Command
final case class Other(value: String) extends Command

def parse(s: String): Command =
s match {
case "noop" => Noop
case s"something $rem" => Something(rem.extractInts)
case s if s.nonEmpty => Other(s)
case _ => s.failedToParse
}
}
Expand All @@ -28,16 +30,16 @@ object Advent00 {
input.parseList("\n", Command.parse)

def part1(data: Parsed): Int =
data.length
data.length + 1234567

def part2(data: Parsed): Int =
data.length
data.length + 1234567

def parseFile(fileName: String): Parsed =
parse(readFileText(fileName))

def main(args: Array[String]): Unit = {
val realData: Parsed = parseFile("2023/00.txt")
val realData: Parsed = parseFile("2023/02.txt")

println(s"Part 1: ${part1(realData)}")
println(s"Part 2: ${part2(realData)}")
Expand Down
16 changes: 8 additions & 8 deletions scala2/src/test/scala/jurisk/adventofcode/Advent00Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import Advent00._
import org.scalatest.matchers.should.Matchers._

class Advent00Spec extends AnyFlatSpec {
"Advent00" should "test part 1" ignore {
part1(parseFile("2023/00-test.txt")) shouldEqual 12345678
"Advent00" should "test part 1" in {
part1(parseFile("2023/02-test.txt")) shouldEqual 5 + 1234567
}

it should "test part 2" ignore {
part2(parseFile("2023/00-test.txt")) shouldEqual 12345678
it should "real part 1" in {
part1(parseFile("2023/02.txt")) shouldEqual 100 + 1234567
}

it should "real part 1" ignore {
part1(parseFile("2023/00.txt")) shouldEqual 12345678
it should "test part 2" in {
part2(parseFile("2023/02-test.txt")) shouldEqual 5 + 1234567
}

it should "real part 2" ignore {
part2(parseFile("2023/00.txt")) shouldEqual 12345678
it should "real part 2" in {
part2(parseFile("2023/02.txt")) shouldEqual 100 + 1234567
}
}

0 comments on commit f1ec3d6

Please sign in to comment.