This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Brute forcing the 24 puzzle (https://en.wikipedia.org/wiki/24_(puzzle)) and friends | |
## We create all permutations of maths signs and numbers (e.g. 1 + 1 + 1 + 1, 2 + 1 + 1 + 1, ..., 1 - 1 + 1 + 1, ...) | |
operators <- c("+", "-", "*", "/") | |
digits <- as.character(1:9) ## numbers to be used in the game | |
d_0 <- expand.grid(digit1 = digits, operator1 = operators, | |
digit2 = digits, operator2 = operators, | |
digit3 = digits, operator3 = operators, | |
digit4 = digits, stringsAsFactors = FALSE) |