Monthly Archives: January 2023

Competitive programming in Haskell: Infinite 2D array, Levels 2 and 3

In a previous post, I challenged you to solve Infinite 2D Array using Haskell. As a reminder, the problem specifies a two-parameter recurrence , given by for for for . Last time, we derived a formula for that involves only … Continue reading

Posted in competitive programming, haskell | Tagged , , | 1 Comment

Binary search over floating point representations

I got some good feedback on my last post about binary search, and thought it was worth a follow-up post. An important fix First things first: commenter Globules pointed out that doing (l+r) `div` 2 can overflow; my initial, glib … Continue reading

Posted in haskell | Tagged , , , | Leave a comment

Competitive programming in Haskell: better binary search

Binary search is a workhorse of competitive programming. There are occasional easy problems where binary search is the solution in and of itself; more often, it’s used as a primitive building block of more complex algorithms. It is often presented … Continue reading

Posted in competitive programming, haskell | Tagged , , | 23 Comments