Skip to content

Commit

Permalink
⚡️ .par 'cause deal with it
Browse files Browse the repository at this point in the history
  • Loading branch information
twentylemon committed Dec 22, 2024
1 parent 10788d4 commit 0835372
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/scala/org/lemon/advent/year2024/Day22.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package org.lemon.advent.year2024

import org.lemon.advent.lib._

import scala.collection.parallel.CollectionConverters._

private object Day22:

def parse(input: String) = input.linesIterator.map(_.toLong)
def parse(input: String) = input.linesIterator.map(_.toLong).toSeq

extension (x: Long)
def mix(y: Long) = x ^ y
Expand Down Expand Up @@ -33,7 +35,7 @@ private object Day22:
.toMap

def part2(input: String) =
val stores = parse(input)
val stores = parse(input).par
.map(sequences)
.toSeq
val best = stores.flatMap(_.keys).toSet.maxBy(seq => stores.map(_.getOrElse(seq, 0L)).sum)
Expand Down

0 comments on commit 0835372

Please sign in to comment.