Ver código fonte

[Haskell][25] Adding Solution

Vinicius Teshima 4 meses atrás
pai
commit
a8bafc5a2b
1 arquivos alterados com 17 adições e 0 exclusões
  1. 17 0
      haskell/src/0025.hs

+ 17 - 0
haskell/src/0025.hs

@@ -0,0 +1,17 @@
+
+import Utils
+
+import Data.Tuple
+
+fibonacciWhile :: (Integer -> Bool) -> (Int, Integer)
+fibonacciWhile f = go' 1 1 1
+  where
+    go' i f1 f2
+      | f f1      = go' (i+1) (f1+f2) f1
+      | otherwise = (i, f1)
+
+solution :: Int
+solution = (fibonacciWhile (\x -> (length $ show x) < 1000) |> fst) + 1
+
+main :: IO ()
+main = putStrLn ("Solution: " ++ show solution)