Skip to content

Commit

Permalink
Remove needless usage of ListBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
flvrone committed Dec 24, 2024
1 parent 314aef0 commit 9da43d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 3 additions & 6 deletions 2/dampened_check.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@

package advent24.dampenedcheck

import scala.collection.mutable.ListBuffer
import scala.collection.mutable.TreeSet

@main
def main2(inputFileName: String): Unit =
val path: os.Path = os.pwd / os.SubPath(inputFileName)
val lines: Seq[String] = os.read.lines(path)

val buff = new ListBuffer[List[Int]]()
val reports = for line <- lines yield
line.split("\\s+").map(_.toInt).toList

for line <- lines do
buff += line.split("\\s+").map(_.toInt).toList

println(dampenedSafeReports(buff.toList))
println(dampenedSafeReports(reports.toList))

enum LevelsTrend:
case Unknown, Increasing, Decreasing, Broken
Expand Down
10 changes: 3 additions & 7 deletions 2/safety_check.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@

package advent24.safetycheck

import scala.collection.mutable.ListBuffer

@main
def main1(inputFileName: String): Unit =
val path: os.Path = os.pwd / os.SubPath(inputFileName)
val lines: Seq[String] = os.read.lines(path)

val buff = new ListBuffer[List[Int]]()

for line <- lines do
buff += line.split("\\s+").map(_.toInt).toList
val reports = for line <- lines yield
line.split("\\s+").map(_.toInt).toList

println(countSafeReports(buff.toList))
println(countSafeReports(reports.toList))

enum LevelsTrend:
case Unknown, Increasing, Decreasing, Broken
Expand Down

0 comments on commit 9da43d8

Please sign in to comment.