~stick/challenges

76bd05163ecfe049c82245612f35bf099c66d574 — Stick 3 months ago 88a6a73
aoc2017: scalafmt
1 files changed, 5 insertions(+), 3 deletions(-)

M advent_of_code/2017/aoc2017/src/main/scala/Main.scala
M advent_of_code/2017/aoc2017/src/main/scala/Main.scala => advent_of_code/2017/aoc2017/src/main/scala/Main.scala +5 -3
@@ 154,7 154,7 @@ object Main extends App {

  printf("\n+++ DAY 07 +++\n")
  val in7 = readFile("input07.txt")
                    .map(_.split(" ").map(_.trim.stripSuffix(",")))
    .map(_.split(" ").map(_.trim.stripSuffix(",")))
  val up = Map[String, (Int, ListBuffer[String])]()
  var down = Map[String, String]()
  for (line <- in7) {


@@ 170,8 170,10 @@ object Main extends App {
    up(line(0)) = node
  }
  val root = up.keySet.diff(down.keySet).head
  def checkWeights(node: String,
                   tree: Map[String, (Int, ListBuffer[String])]): (Boolean, Int) = {
  def checkWeights(
      node: String,
      tree: Map[String, (Int, ListBuffer[String])]
  ): (Boolean, Int) = {
    if (tree(node)._2.length > 0) {
      val recurse = for (n <- tree(node)._2) yield checkWeights(n, tree)
      val weights = for (n <- recurse) yield n._2