-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.hs
executable file
·45 lines (34 loc) · 1.51 KB
/
Test.hs
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
33
34
35
36
37
38
39
40
41
42
43
44
import Data.Set
import Data.List.Split
import Data.List
import Piece
import Init
import Solve
main = do
let pieces =
[ ['I', 'P', 'P', 'Y', 'Y', 'Y', 'Y', 'V', 'V', 'V']
, ['I', 'P', 'P', 'X', 'Y', 'L', 'L', 'L', 'L', 'V']
, ['I', 'P', 'X', 'X', 'X', 'F', 'Z', 'Z', 'L', 'V']
, ['I', 'T', 'W', 'X', 'F', 'F', 'F', 'Z', 'U', 'U']
, ['I', 'T', 'W', 'W', 'N', 'N', 'F', 'Z', 'Z', 'U']
, ['T', 'T', 'T', 'W', 'W', 'N', 'N', 'N', 'U', 'U']
]
board = [(row, col) | row <- [0 .. 11], col <- [0 .. 4]]
zeroProgress :: Progress Cell
zeroProgress = initialProgress board pieces
print $ "Piece count = " ++ show (length $ unused zeroProgress)
let firstSolution :: [Piece]
firstSolution = used -- the pieces used for the first solution
$ head -- the first solution
$ solutionsHylo -- get the list of solutions
$ zeroProgress -- no progress yet
mapM_ print firstSolution
let decorate piece = [ (loc,name) | loc <- getLocations piece, let name = getName piece ]
prettySolution :: [[Char]]
prettySolution = chunksOf 5 -- 5 columns at a time for printing.
$ fmap snd -- Drop the locations - keep the names.
$ sort -- Sort by location.
$ concat -- gather all the named locations
$ decorate <$> firstSolution -- Add names to locations
return ()
-- mapM_ print prettySolution