Skip to content

Instantly share code, notes, and snippets.

@alcides
Created November 26, 2011 01:35
Show Gist options
  • Save alcides/1394809 to your computer and use it in GitHub Desktop.
Save alcides/1394809 to your computer and use it in GitHub Desktop.
type DataStore = [(Int, Int)]
iter :: Int -> DataStore -> Int -> (DataStore, Int)
iter rem ks d = ( (d, rem `div` d):ks, rem `mod` d)
wrapper :: Int -> DataStore -> Int -> (DataStore, Int)
wrapper re ds 1 = (ds, re)
wrapper re ds d = wrapper re' ds' (d `div` 2)
where (ds', re') = iter re ds d
page_spread_count :: Int -> ([(Int, Int)], Int)
page_spread_count i = wrapper i [] 16
@md2perpe
Copy link

I found your gist, read the "contest" and made my own solution: https://gist.github.com/1395553
The last reminder is returned in the list, for the key 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment