Skip to content

Commit

Permalink
fix binsearch bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 6, 2023
1 parent 26044ff commit 887aa42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions solutions/src/2023/06.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ ways (t, d) = hi - lo + 1
where
valid hold = (t - hold) * hold > d
mid = t `div` 2 -- the midpoint is the best we can get
lo = binSearch (not . valid) 0 (mid + 1) + 1
hi = binSearch valid lo t
lo = binSearch (not . valid) 0 mid + 1
hi = binSearch valid mid t

binSearch ::
(Int -> Bool) {- ^ predicate -} ->
Expand Down

0 comments on commit 887aa42

Please sign in to comment.