Sudoku Science

A popular puzzle helps researchers dig into deep math

4 min read
photo of Sudoko puzzle
IEEE Spectrum

aNumber Fad: A reader examines a Sudoko puzzle in The Independent, London, last May.Photo: Adrian Dennis/Getty Images

Millions of people around the world are tackling one of the hardest problems in computer science—without even knowing it. The logic game Sudoku is a miniature version of a longstanding mathematical challenge, and it entices both puzzlers, who see it as an enjoyable plaything, and researchers, who see it as a laboratory for algorithm design.

Sudoku has become a worldwide puzzle craze within the past year. Previously known primarily in Japan, it now graces newspapers, Web sites, and best-selling books in dozens of countries. A puzzle consists of a 9-by-9 grid made up of nine 3-by-3 subgrids. Digits appear in some squares, and based on these starting clues, a player completes the grid so that each row, column, and subgrid contains the digits 1 through 9 exactly once. An easy puzzle requires only simple logical techniques—if a subgrid needs an 8, say, and two of the columns running through it already hold an 8, then the subgrid’s 8 must go in the remaining column. A hard puzzle requires more complex pattern recognition skills; for instance, if a player computes all possible digits for each cell in a subgrid and notices that two cells have exactly the same two choices, those two digits can be eliminated from all other cells in the subgrid. No matter the difficulty level, however, a dedicated puzzler can eventually crack a 9-by-9 Sudoku game.

A computer solves a 9-by-9 Sudoku within a second by using logical tricks that are similar to the ones humans use, but finishes much faster. On a large scale, however, such shortcuts are not powerful enough, and checking the explosive number of combinations becomes impossible, even for the world’s fastest computers. And no one knows of an algorithm that’s guaranteed to find a solution without trying out a huge number of combinations. This places Sudoku in an infamously difficult class, called NP-complete, that includes problems of great practical importance, such as scheduling, network routing, and gene sequencing.

Sudoku has stirred up tremendous interest in mathematics generally, especially among youngsters. “I mean, it’s cool to play Sudoko”

“The question of whether there exists an efficient algorithm for solving these problems is now on just about anyone’s list of the Top 10 unsolved problems in science and mathematics in the world,” says Richard Korf, a computer scientist at the University of California at Los Angeles. The challenge is known as P = NP, where, roughly speaking, P stands for tasks that can be solved efficiently, and NP stands for tasks whose solution can be verified efficiently. (For example, it is easy to verify whether a complete Sudoku is correctly filled in, even though the puzzle may take quite a lot of time to solve.)

As a member of the NP-complete subset, Sudoku is an ideal tool for investigating the whole class of NP problems: an efficient algorithm for any NP-complete problem—the toughest of NP problems—automatically provides an efficient algorithm for solving all. Although most experts believe that no such algorithm exists, they continually search for improved algorithms that provide shorter, if not the very shortest, paths to solutions.

Sudoku has already led some researchers to concrete advances in algorithm design. At the Intelligent Information Systems Institute at Cornell University, Ithaca, N.Y., director Carla Gomes experiments with Latin Squares, a version of Sudoku without subgrids. Gomes realized that a computer can take either seconds or eons to solve the very same puzzle—and that this drastic difference depends on something as simple as the order in which the computer considers cells in the grid. Solving a particular grid might not be inherently time-consuming, Gomes saw, but might just call for a slightly different approach.

Now many state-of-the-art hardware verification programs incorporate Gomes's findings. “The idea is, basically, you run your program, and if it's taking too long you restart it” with a new ordering, Gomes says, “because your computer may end up getting into an unlucky run, and hopefully the next run will be a lucky one.” Gomes hopes to further improve algorithms by studying how people combine various rules and patterns when they play Sudoku.

Sudoku follows in a long tradition of artificial intelligence research on games, most notably chess. But some of AI's most important advances stem from more modest games. The route-finding algorithm that powers car navigation systems, for instance, was first demonstrated on the Sliding Tile puzzle, a child’s toy in which a player tries to move 15 tiles around a grid so that their surfaces form a picture. The same algorithm helps video game characters steer through virtual worlds. “This is an algorithm developed back in 1968 in abstract kinds of things,” says UCLA’s Korf, who himself has explored algorithms for the Rubik’s Cube. “It’s used all the time.”

Could the Sudoku craze end up leading to breakthroughs in computer science? Perhaps, one way or another. “I’ll tell you one of the things that is important for engineering,” says Michael Mepham, a puzzlemaker in Great Britain whose Sudokus appear in The Daily Telegraph and The Los Angeles Times. “And that is the interest that Sudoku has stirred up in math generally, especially amongst youngsters. I mean, it’s cool to play Sudoku.”

This article is for IEEE members only. Join IEEE to access our full archive.

Join the world’s largest professional organization devoted to engineering and applied sciences and get access to all of Spectrum’s articles, podcasts, and special reports. Learn more →

If you're already an IEEE member, please sign in to continue reading.

Membership includes:

  • Get unlimited access to IEEE Spectrum content
  • Follow your favorite topics to create a personalized feed of IEEE Spectrum content
  • Save Spectrum articles to read later
  • Network with other technology professionals
  • Establish a professional profile
  • Create a group to share and collaborate on projects
  • Discover IEEE events and activities
  • Join and participate in discussions