Explorar el Código

added naive for comparison

master
Thorn Avery hace 3 años
padre
commit
250b891383
Se han modificado 3 ficheros con 18 adiciones y 0 borrados
  1. +1
    -0
      .gitignore
  2. BIN
      benchmark.png
  3. +17
    -0
      naiveEgg.hs

+ 1
- 0
.gitignore Ver fichero

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

BIN
benchmark.png Ver fichero

Antes Después
Anchura: 367  |  Altura: 130  |  Tamaño: 4.8KB

+ 17
- 0
naiveEgg.hs Ver fichero

@@ -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


Cargando…
Cancelar
Guardar