Infinite House of Pancakes in Haskell
I'll refactor so every line tells the reader something about the program.

{-# LANGUAGE ScopedTypeVariables #-}
import Text.Printf
import Control.Monad
import Data.List.Split (splitPlaces)
import Safe (headNote)

main :: IO ()
main = interact                                                                -- no side effects
  $ (\f -&gt; unlines . zipWith f [1..] . subList [2,4..] . lines)                -- embarassingly parallel
  $ (\solve (i :: Int) -&gt; printf "Case #%d: %d" i . solve . map read . words)  -- mere math
  $ (\cost (s :: [Int]) -&gt; minimum [cost l s | l &lt;- [1 .. maximum s]])         -- brute optimization
  $ \l -&gt; (+l) . sum . map ((`div` l) . subtract 1)

-- This gets a name because we ought to be importing it from a library.
subList :: [Int] -&gt; [a] -&gt; [a]
subList is = map (headNote "subList: index list not strictly ascending")
  . drop 1 . splitPlaces (zipWith (-) is $ 0:is)