How to solve Sudoku with R
In this post we discuss how to write an R script to solve any Sudoku puzzle. There are some R packages to handle this, but in our case, we'll write our own solution. For our purposes, we'll assume the input Sudoku is a 9x9 grid. At the end result, each row, column, and 3x3 box needs to contain exactly one of each integer 1 through 9. Learn more about data science by checking out the great curriculum at 365 Data Science! Step 0) Define a sample board Let's define a sample Sudoku board for testing. Empty cells will be represented as zeroes. [code lang="R"] board <- matrix( c(0,0,0,0,0,6,0,0,0, 0,9,5,7,0,0,3,0,0, 4,0,0,0,9,2,0,0,5, 7,6,4,0,0,0,0,0,3, 0,0,0,0,0,0,0,0,0, 2,0,0,0,0,0,9,7,1, 5,0,0,2,1,0,0,0,9, 0,0,7,0,0,5,4,8,0, 0,0,0,8,0,0,0,0,0), byrow = T, ncol = 9 ) [/code] Step 1) Find the empty cells…