mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-08 18:13:36 +00:00
move comparator functions into util
This commit is contained in:
@@ -24,14 +24,7 @@ func parseLines(r io.Reader) int {
|
||||
for scanner.Scan() {
|
||||
nums := util.IntsFromString(scanner.Text())
|
||||
|
||||
cmpIncrease := func(nums []int, i int) bool {
|
||||
return nums[i-1] >= nums[i]
|
||||
}
|
||||
cmpDecrease := func(nums []int, i int) bool {
|
||||
return nums[i-1] <= nums[i]
|
||||
}
|
||||
|
||||
if check(nums, cmpIncrease) || check(nums, cmpDecrease) {
|
||||
if check(nums, util.CmpIncrease) || check(nums, util.CmpDecrease) {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user