mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30:47 +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
|
var occurrences int
|
||||||
for _, n := range right[indx:] {
|
for _, n := range right[indx:] {
|
||||||
if n == k {
|
if n > k {
|
||||||
occurrences++
|
break
|
||||||
}
|
}
|
||||||
|
occurrences++
|
||||||
}
|
}
|
||||||
similarity += k * v * occurrences
|
similarity += k * v * occurrences
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user