Skip to content

Instantly share code, notes, and snippets.

@ritesh
Created December 21, 2025 13:01
Show Gist options
  • Select an option

  • Save ritesh/7de3951b64a8b1fbfdcd4109d3a1e111 to your computer and use it in GitHub Desktop.

Select an option

Save ritesh/7de3951b64a8b1fbfdcd4109d3a1e111 to your computer and use it in GitHub Desktop.
day2.scala
@main def main(): Unit = {
val path = os.Path("/tmp/1.txt")
val lineStream: geny.Generator[String] = os.read.lines.stream(path)
println("Num zeroes: " + turn_dial_part2(lineStream))
}
def turn_dial_part2(gen: geny.Generator[String]): Int = {
var dialPos = 50
gen
.map(input => {
val direction = if input.head == 'L' then -1 else 1
(0 until input.tail.toInt)
.map(i => {
// println("Dial is moving by " + i)
dialPos = (dialPos + direction) % 100
// println("Dial pos is now " + dialPos)
if dialPos == 0 then 1 else 0
})
.sum
})
.sum
}
@ritesh
Copy link
Author

ritesh commented Dec 21, 2025

Should be day 1 part 2 not day 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment