added naive for comparison
This commit is contained in:
parent
448981d4d8
commit
250b891383
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
*.o
|
||||
*.swp
|
||||
eggdrop
|
||||
neggdrop
|
||||
|
BIN
benchmark.png
Normal file
BIN
benchmark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
17
naiveEgg.hs
Normal file
17
naiveEgg.hs
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user