Type Classes

Type Classes

Share this post

Type Classes
Type Classes
Water Monoids

Water Monoids

Solving that water-puddles problem, using as many monoids as possible.

Chris Martin's avatar
Chris Martin
Feb 20, 2017
∙ Paid
1

Share this post

Type Classes
Type Classes
Water Monoids
Share

In the toy problem described by I Failed a Twitter Interview, we are given a list of integers

3, 2, 1, 4, 2

representing the heights of walls

3 2 1 4 2

and we imagine pouring water onto this structure such that puddles accumulate in the gaps.

We are then asked: How much water is held by the structure? (In the above example, the answer is 3).

Monoids

I find mys…

Keep reading with a 7-day free trial

Subscribe to Type Classes to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Mission Valley Software LLC
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share