Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lazy val root = project
.settings(
organization := "com.horothesun",
name := "advent-of-code-2024",
scalaVersion := "3.7.2",
scalaVersion := "3.7.3",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "kittens" % kittensVersion,
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/Day02.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ object Day02:
case _ :: tail => ls.zip(tail).forall((l, r) => l.differsFrom(min = 1, max = 3)(r))

def safety(ls: List[Level]): Safety =
if ((isAllIncreasing(ls) || isAllDecreasing(ls)) && areAllDeltasBetween1And3(ls)) Safe else Unsafe
if (isAllIncreasing(ls) || isAllDecreasing(ls)) && areAllDeltasBetween1And3(ls) then Safe else Unsafe

extension [A](nel: NonEmptyList[A])
def removed(elementAt: Int): List[A] =
val as = nel.toList
if (elementAt < 0 || nel.length <= elementAt) as
if elementAt < 0 || nel.length <= elementAt then as
else // 0 <= idx && idx < nel.length
as.take(elementAt) ++ as.drop(1 + elementAt)

Expand Down