added naive for comparison

This commit is contained in:
Thorn Avery 2021-03-12 15:05:46 +13:00
parent 448981d4d8
commit 250b891383
3 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.o *.o
*.swp *.swp
eggdrop eggdrop
neggdrop

BIN
benchmark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

17
naiveEgg.hs Normal file
View File

@ -0,0 +1,17 @@
eggDrop :: Integer -> Integer -> Integer
eggDrop n k
| k == 1 || k == 0 || n == 1 = k
| otherwise = 1 + (minimum $ map (\i -> f i) [1..k])
where
f i = max (eggDrop (n-1) (i-1)) (eggDrop n (k-i))
-----------------
-- gross io bs --
-----------------
main :: IO ()
main = do
l <- getLine
let (n:k:_) = map read $ words l :: [Integer]
putStrLn $ show $ eggDrop n k