How to solve Sudoku with R

How to solve Sudoku with R

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…
Read More
How to schedule a Python script on a Mac

How to schedule a Python script on a Mac

Python, System Administration
In a previous article, we talked about how to run Python from the Windows Task Scheduler. This post will cover how to schedule Python tasks on a Mac operating system as well as give an overview of the schedule package. Using crontab on Mac Python tasks can be scheduled on Mac using crontab. To do that, first, open up the Terminal. Then, we need to modify the crontab file. We can do that by typing crontab -e. This will open crontab in the default editor, which is typically vim. You can change the editor by adding the editor name in front of our command - for example, to modify the crontab file using nano, we can run nano crontab -e (followed by enter). Next, we need to add in a…
Read More