Created
December 1, 2018 19:09
-
-
Save avjinder/18bbfd27958cbb656922086ef7d55b18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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