-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsuedoCode.txt
38 lines (34 loc) · 866 Bytes
/
psuedoCode.txt
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
INIT puzzleList = NEW LIST
BEGIN FindSolutions
INIT puzzle = RANDOM puzzle WITH DUPLICATIONS
buildNewPuzzlesFrom(puzzle)
END
BEGIN buildNewPuzzlesFrom(puzzle)
INIT board = NEW PUZZLE WITH puzzle(0, 0) AS FIRST ELEMENT
INIT unPlaced = VECTOR OF EVERYTHING IN puzzle BUT FIRST
recTryPlacingPieces(board, unplaced)
END
BEGIN recTryPlacingPieces(board, unplaced)
FOR i FROM 0 TO board.rows
FOR j FROM 0 TO board.cols
for k FROM 0 TO unplaced.size()
if tryPiece(board, i, j, unplaced[k])
REMOVE unplaced[k] FROM unplaced
recTryPlacingPieces(board, unplaced)
ENDIF
ENDFOR
ENDFOR
ENDFOR
puzleList.add(board)
END
BEGIN tryPiece(board, row, col, piece)
IF !board(row, col).isPlaced
FOR rotationAmount FROM 0 TO 3
IF board.fits(piece, row, col)
board(row, col) = piece
RETURN true
ENDIF
ENDFOR
ENDIF
RETURN false
END