mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 14:20:48 +00:00
break early once value in right surpasses k in left
This commit is contained in:
parent
25b6db75c8
commit
3a10d377ef
@ -34,9 +34,10 @@ func Solve() (int, error) {
|
||||
|
||||
var occurrences int
|
||||
for _, n := range right[indx:] {
|
||||
if n == k {
|
||||
occurrences++
|
||||
if n > k {
|
||||
break
|
||||
}
|
||||
occurrences++
|
||||
}
|
||||
similarity += k * v * occurrences
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user