Skip to content

Instantly share code, notes, and snippets.

@avjinder
Created December 1, 2018 19:09
Show Gist options
  • Save avjinder/18bbfd27958cbb656922086ef7d55b18 to your computer and use it in GitHub Desktop.
Save avjinder/18bbfd27958cbb656922086ef7d55b18 to your computer and use it in GitHub Desktop.
fun partTwo(input: String): Int {
var frequency = 0
val diff = measureTimeMillis {
val lines = input.split("\n").map { it.toIntOrNull() ?: 0 }
val frequencies = mutableSetOf<Int>()
for (i in 0..Int.MAX_VALUE) {
frequency += lines[i % lines.count()]
if (!frequencies.add(frequency)) break
}
}
println("Time(ms): $diff")
return frequency
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment