File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,17 @@ rating :: Matrix Int -> Point -> Point -> Int
22
22
rating matrix x y = go (getCandidates 1 x) [y] 1
23
23
where
24
24
go :: [Point ] -> [Point ] -> Int -> Int
25
- go _ _ 6 = 0
26
- go leftFront rightFront step =
27
- let leftFront' = concatMap (getCandidates (1 + step)) leftFront
28
- rightFront' = concatMap (getCandidates (9 - step)) rightFront
29
- intersection = intersect leftFront rightFront
30
- in if not (null intersection)
31
- then length intersection
32
- else go leftFront' rightFront' (step + 1 )
25
+ go leftFront rightFront step
26
+ | step > 5 = 0
27
+ | step < 5 =
28
+ let leftFront' = concatMap (getCandidates (1 + step)) leftFront
29
+ rightFront' = concatMap (getCandidates (9 - step)) rightFront
30
+ in go leftFront' rightFront' (step + 1 )
31
+ | otherwise =
32
+ let intersectionA = intersect leftFront rightFront
33
+ intersectionB = intersect rightFront leftFront
34
+ intersection = if length intersectionA > length intersectionB then intersectionA else intersectionB
35
+ in length intersection
33
36
34
37
getCandidates :: Int -> Point -> [Point ]
35
38
getCandidates value (row, col) =
You can’t perform that action at this time.
0 commit comments