mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
560 B
35 lines
560 B
package main |
|
|
|
func recursion(b board, array []tetrimino, idx int) bool { |
|
if idx == len(array) { |
|
return true |
|
} |
|
for i := range b { |
|
for j := range b[i] { |
|
if !b.check(i, j, array[idx]) { |
|
continue |
|
} |
|
b.put(i, j, idx, array[idx]) |
|
if recursion(b, array, idx+1) { |
|
return true |
|
} |
|
b.remove(i, j, array[idx]) |
|
} |
|
} |
|
return false |
|
} |
|
|
|
func solve(array []tetrimino) board { |
|
square := 2 |
|
for square*square < len(array)*4 { |
|
square++ |
|
} |
|
for { |
|
b := makeBoard(square) |
|
square++ |
|
if !recursion(b, array, 0) { |
|
continue |
|
} |
|
return b |
|
} |
|
}
|
|
|