Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View courtiol's full-sized avatar
🇫🇷

Alexandre Courtiol courtiol

🇫🇷
View GitHub Profile
## 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)