From fec6ad311f6ae211b9ba05050d23fa0596eb4a85 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 18 Dec 2022 03:18:09 +1030 Subject: [PATCH] remove superfluous indent --- 2022/day07.scala | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/2022/day07.scala b/2022/day07.scala index eb5c320..31c79a2 100644 --- a/2022/day07.scala +++ b/2022/day07.scala @@ -15,14 +15,13 @@ def cd(cwd: String, to: String): String = to match var cwd = "" // We append the / at time of use val folders = scala.collection.mutable.HashSet[String](cwd) val fileSizes = scala.collection.mutable.HashMap[String, Int]() - for line <- inputLines do - line match - case cdPattern(dir) => - cwd = cd(cwd, dir) - folders += cwd - case fileSizePattern(sizeStr, filename) => - fileSizes += s"$cwd/$filename" -> sizeStr.toInt - case _ => {} // "$ ls", "dir ..." + for line <- inputLines do line match + case cdPattern(dir) => + cwd = cd(cwd, dir) + folders += cwd + case fileSizePattern(sizeStr, filename) => + fileSizes += s"$cwd/$filename" -> sizeStr.toInt + case _ => {} // "$ ls", "dir ..." // Very inefficient way of calculating folder sizes, but cute enough val folderSizes = folders.map(f => (f, fileSizes.filter((k,v) => k startsWith s"$f/").values.sum)).toMap