Solves a Dominosa (Domino Solitaire) puzzle given a grid of pip values.
Value
A list with components:
domino_idsAn integer matrix of the same dimensions as
pipswhere cells belonging to the same domino share the same integer value.pipsThe input
pipsmatrix.ppnA string of Portable Piecepack Notation for the solution.
See also
https://www.solitairelaboratory.com/puzzlelaboratory/DominoGG.html and https://puzzlebreaks.com/dominosa/ for more information about Dominosa.
Examples
pips <- matrix(c(0, 1, 0, 1, 3,
3, 1, 0, 2, 2,
3, 2, 1, 0, 3,
2, 3, 1, 0, 2), nrow = 4L, byrow = TRUE)
s <- solve_dominosa(pips)
if (rlang::is_installed(c("piecepackr", "ppn"))) {
g <- ppn::read_ppn(textConnection(s$ppn))[[1]]
envir <- piecepackr::game_systems(round = TRUE)
ppn::plot_move(g, open_device = FALSE, annotate = FALSE, envir = envir, scale = 0.95)
}