Python Programming for the Puzzled

In this course, we use Python to solve a variety of puzzles. Two of the puzzles involve the game of chess. (Image by Brett Paci at MIT OpenCourseWare.)

By Joe Pickett, OCW Publication Director

Python Programming for the Puzzled

Those Sudoku number grids that look so easy but can be so exasperating—wouldn’t it be great to write a program that can solve every one of them?

Imagine you’re a magician, and your neat trick is to read the minds of the people in the audience. They’ve seen some cards pulled from a deck. You boast that you can read their minds and pick the fifth card, which is amazing, because you’ve already missed the first four! How can you pull this trick off?

The bike rack on your car has gotten loose and needs to be re-secured. All you need is a bolt and a nut that match the size of a hole in a metal tube. Luckily, you’ve got lots of bolts and nuts in a couple of jars on a shelf. Maybe it’s finally time to see which bolts and nuts fit together. But you don’t have all day. You need to get this done quickly. You’re meeting up with friends  . . .

Solving Algorithmic Puzzles with Python

These vexing challenges might seem about as different from each other as can be, but the puzzles they present are all solvable by algorithms and a little Python programming!

That’s right—you can program magic, and mechanics, and Sudoku grids right from your home computer. All you need is a little help from Professor Srini Devadas, now available in his course 6.S095 Programming for the Puzzled.

Taught during the IAP period of January 2018, the course has on its OCW site full video lectures, a prose description of each puzzle challenge, the necessary Python code, and the solution to the puzzle.

Professor Devadas is a master at making programming fun by tying it to real-world conundrums. He’s won an MIT MacVicar Fellowship for being such a great teacher, and in this course he’s at the top of his game.

Professor Srini Devadas begins his explanation of how he “read” the minds of the class in the “You Can Read Minds” puzzle.

There’s a square courtyard you have to tile. It should be an easy job, only the tile you’ve been given isn’t square. It’s L-shaped. And there’s this statue that you’ll have to work around. Don’t fret! Professor Devadas has the magic formula!

How can you place eight queens on a chessboard such that no queen attacks any other? How about if you have a chessboard of any size and a number of queens matching that board’s number of columns or rows? You don’t have to be a chess master to solve this one!

Professor Devadas knows how to foster creative thinking with programming, and the puzzles he unravels will surely lead his students to solve even more mind-bending puzzles in the future.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s