File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ module Bus (enough ) where
2
+
3
+ -- https://www.codewars.com/kata/5875b200d520904a04000003/train/haskell
4
+
5
+ enough :: Int -> Int -> Int -> Int
6
+ enough cap on wait
7
+ | diff < 0 = abs diff
8
+ | otherwise = 0
9
+ where
10
+ diff = cap - on - wait
Original file line number Diff line number Diff line change
1
+ module BusSpec where
2
+
3
+ import Test.Hspec
4
+ import Bus (enough )
5
+
6
+ spec :: Spec
7
+ spec = do
8
+ describe " Fixed Tests" $ do
9
+ mapM_ (\ (c@ (Case cap on wait), ans) -> it (show c) $ enough cap on wait `shouldBe` ans)
10
+ [ (Case 10 5 5 , 0 )
11
+ , (Case 100 60 50 , 10 )
12
+ , (Case 20 5 5 , 0 )
13
+ ]
14
+
15
+ data Case = Case Int Int Int
16
+
17
+ instance Show Case where
18
+ show (Case cap on wait) =
19
+ " cap: " ++ show cap ++ " , " ++
20
+ " on: " ++ show on ++ " , " ++
21
+ " wait: " ++ show wait
You can’t perform that action at this time.
0 commit comments