Simatic sudoku helper.

knutabru

Member
Join Date
Jan 2006
Location
Trondheim
Posts
46
Hello.

I want to share with you a program that can help you, and sometimes solve a sudoku puzzle.
It was started on it in my last days of vacation when I started developing a PLC withdrawal syndrome.

Yes, I know I am some years late as the big sudoku hype mostly is over by now. But I was quite impressed when I saw this video of a LEGO Mindstorm that is able to scan and interpret a Sudoku puzzle on paper (OCR), solve it and then write down the solution.
https://youtu.be/Mp8Y2yjV4fU

At least a PLC should be able to solve a puzzle, and primary not using brute force, but instead use reasoning.
So then I went at it and found out two ways of reasoning where the numbers should go.

The main idea is to reduce the allowed numbers for each cell until there was only one number allowed in the cell in focus.

I call it Sudoku helper since it will not solve the hardest ones.

If anyone have an interest, I'm open for suggestions for further improvements or optimizing of the code.

I know there is other ways of solving this with boolean logic, but I wanted to try to hone my SCL experience.
Ref:http://www.plctalk.net/qanda/showpost.php?p=138239&postcount=13

You should be able to run the project on PLCsim and Wincc Runtime without much hassle, just set the PLCsim interface to Profibus. The mainscreen on the HMI is "01_Solving"

I have made some VAT-tables for a crude way of entering problems into the DB. I started to make a program that checks if the problem is a valid one, but I got bored and went straight to the problemsolving methods instead.

I have written most of it in English, some of it is in Norwegian, but that is abandoned program bits intended for later development.


Since the archived project is almost 3MB, I share it on Dropbox:
https://www.dropbox.com/s/ciozqzhgne605l3/SudokuHelper_20150922.zip?dl=0

-Hope you find something interesting or useful.

Knut A. B.
 
I still solve Sudoku puzzles.
Knutabru, I think I know how you are solving the puzzle.
Using sets or what you call Boolean would be the easy way to solve simple puzzles.
A recursive search would be time consuming but it would be able to solve anything. It is the brute force and ignorance approach but I think the easiest approach.
There are plenty of "rules" or algorithms that make solving Sudoku puzzles faster without trial and error.
Here is an example of one of the simplest rules
http://www.sudokuwiki.org/BUG
Here are advanced examples
http://www.sudoku9981.com/sudoku-solving/fish.php
Have fun.
The thought of writing a Sudoku puzzle in LAD or STL make me cringe.
 
Wouldn't a hexadoku solver be more appropriate for a PLC? And a little bit more challenging?

BTW I wrote a hexadoku helper (not a solver) in Excel a couple of years ago. I don't like the real solvers because they take out the challenge and the fun.
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
71
Dear sir, I am using SIMATIC 300, CPU 315-2DP , (6ES7 315-2AF03-0AB0) VIPA 603-1CC21 A1.0 RAM 32KB, Firmware=V4.0.8 The problem Im using MPI...
Replies
2
Views
162
Hi, I received this SIMATIC S7-300 training kit for maintenance. When I power it up, the PLC doesn't go to RUN mode and the STOP mode led is...
Replies
7
Views
299
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
314
I am utilizing both HMI and SCADA for my project. Both HMI and SCADA have identical tags. When I modify the tag value on HMI, it is reflected in...
Replies
2
Views
142
Back
Top Bottom