DEV Community

Discussion on: Haskell by example - Utopian Tree

Collapse
 
rampion profile image
Noah Luck Easterly • Edited

And then there's always the O(1) solution

solve :: Int -> Int
solve spurts = (2 ^ (1 + doubleAndIncrease) - 1) * (2 ^ finalDouble)
  where (doubleAndIncrease,finalDouble) = spurts `quotRem` 2
Collapse
 
jvanbruegge profile image
Jan van Brügge

Yeah, but that does not show off haskell that well :D