# Toy Robot to Solve Sudoku (w/ Video)

##### Sep 03, 2009 by Lin Edwardsweblog

(PhysOrg.com) -- A Swedish programmer, Hans Andersson, has used a Lego Mindstorms NXT kit to develop a robot to solve Sudoku puzzles.

Andersson first purchased the Lego Mindstorms kit for his daughters, but couldn't resist playing with it himself.

The first scans the puzzle and uses an to map out the puzzle's pre-set numbers and blank squares. The robot scans one line at a time, inching forward a little after each line is scanned.

The blurry scanned image is then converted to a black and white binary image to improve the sharpness of the picture. A threshold value calculated by Otsu's Method is used to determine whether each pixel in the image is white or black.

The Otsu Method classes pixels as either foreground or background, and then determines the optimal threshold that minimizes the intra-class variance. Pixels below the threshold are set to black, and those above are set to white.

A thinning algorithm is then used to convert the resulting image of each digit to 1-pixel wide lines. The digits are then examined for features such as their width, and the number and direction of tips on the digit. The digit six, for example, has one tip, which points to the right. Following this procedure for each digit, the robot identifies all the pre-set numbers in the puzzle.

Once the puzzle is mapped, the robot solves it and fills in the blank squares. A recursive backtracking algorithm would normally be used to solve puzzles such as Sudoku, crosswords, or other puzzles in which the solution has several candidates. The method carries out a systematic examination of all possible solutions, and abandons and does not re-visit any that are eliminated.

The Lego Mindstorms processor is too slow to use a backtracking algorithm and it does not allow for recursive functions, so Andersson had to make sure the calculations were optimized. The result is a little robot that can solve Sudoku puzzles and get them right every time, and in only a few minutes.

Explore further: Battle lines drawn around the legality of 'killer robots'

## Related Stories

#### Two Robot Chefs Make Omelets

Dec 04, 2008

(PhysOrg.com) -- No "house of the future" is complete without a household robot to do the cooking and cleaning. Although today´s robots still have a ways to go before substituting for a real live-in maid, ...

#### Video: Swine flu health tips

Apr 30, 2009

Lucile Packard Children’s Hospital has issued some swine flu health tips.

#### N97 mini, X6 and X3: Nokia unveils new smartphones to rival iPhone (w/ Video)

Sep 02, 2009

Nokia, the world's leading mobile phone maker, unveiled Wednesday three new smartphones as the Finnish firm tries to claw back market share from Apple's popular iPhone and RiM's Blackberry.

#### 'Curtain twitching' skylarks keep track of strangers through their songs (w/ Video)

Aug 26, 2009

(PhysOrg.com) -- Skylarks can hear the difference between friendly neighbours and dangerous strangers, and deal with any threatening intruders, says new research by scientists at Queen Mary, University of London.

Aug 19, 2009

Google has developed a formula to predict hot online search topics in what promises to be a boon for businesses eager to target ads that accompany Internet search results.

#### Fish robot as an alternative marine propulsion system of the future (w/Video)

Jun 09, 2009

The team of Darmstadt researchers analyzed videos of fish’s motions and then developed a prototype fish robot that duplicated them, and are now testing it using the locomotional patterns of various species of fish in order ...

## Recommended for you

#### Robots and dinosaurs as Japan holds 'Niconico' offline gala

2 hours ago

Robots and dinosaurs mingled with cosplayers as Japan's largest video-sharing website Niconico on Saturday opened its two-day meet-up gala which is expected to attract more than 100,000 fans for the offline ...

#### Battle lines drawn around the legality of 'killer robots'

Apr 24, 2015

The future of lethal autonomous weapon systems (LAWS) – often referred to in the popular press as "killer robots" – remains uncertain following a week-long meeting in Geneva to discuss their legality. ...

#### The potential for robots to perform human jobs

Apr 20, 2015

Here's a game to play over dinner. One person names a profession that they believe can't be taken over by a machine, and another person has to make a case why it's not so future-proof. We played this game ...

#### Developing a robotic therapist for children

Apr 20, 2015

In collaboration with other national institutions, researchers at Universidad Carlos III de Madrid (UC3M) are designing a new therapeutic tool for motor rehabilitation for children. In this project, an interactive ...

#### Automating logistics for the factory of the future

Apr 20, 2015

Mass production and packaging in factories is already highly automated these days, but the same cannot be said for logistics. Movements of raw materials and finished products still depend heavily on manual ...

#### Japan robot receptionist welcomes shoppers

Apr 20, 2015

She can smile, she can sing and this robot receptionist who started work in Tokyo on Monday never gets bored of welcoming customers to her upmarket shop.