-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path109.hs
More file actions
32 lines (23 loc) · 817 Bytes
/
Copy path109.hs
File metadata and controls
32 lines (23 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Data.List
import Control.Monad
type Hit = (Int, Int)
value (x,y) = x * y
doubles = map (\x -> (x,2)) $ [1..20] ++ [25]
allscores = (0,0) : doubles ++ (map (\x -> (x,1)) $ [1..20] ++ [25]) ++
(map (\x -> (x,3)) $ [1..20])
nubf (a,b,c) (d,e,f) = (a == e) && (b == d)
checkouts' n = do
final <- doubles
guard $ n - (value final) >= 0
second <- allscores
guard $ n - (value second) >= 0
first <- allscores
guard $ n - (value first) >= 0
--let first = n - (value final) - (value second)
-- guard $ (value first) >= 0
-- guard $ first `elem` allscores
guard $ (value final + value first + value second) == n
return (first,second,final)
checkouts n = nubBy nubf $ checkouts' n
ways = map (length . checkouts) [1..99]
answer = sum ways