소스 검색

[Haskell][25] Adding Solution

Vinicius Teshima 4 달 전
부모
커밋
a8bafc5a2b
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  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)