aboutsummaryrefslogtreecommitdiff
path: root/Puzzle3.hs
blob: 4076ace6e1f67820cd33c11dc6a0e16c256b9c85 (plain) (blame)
1
2
3
4
5
f :: Int -> Int
f n = floor $ (sqrt (fromIntegral n - 0.5) + 1) / 2

solve1 :: Int -> Int
solve1 n = let k = f n in abs ((n - 2 - (2 * k - 1)) `mod` (2 * k) - k) + k