Page 2 of 2 [ 27 posts ]  Go to page Previous  1, 2

wbport
Sea Gull
Sea Gull

User avatar

Joined: 16 Sep 2012
Gender: Male
Posts: 220

13 Nov 2022, 11:12 pm

This is something to solve the peg solitaire puzzles on the tables at Cracker Barrel. Cracker Barrel



Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,403
Location: Pennsylvania

14 Nov 2022, 11:08 am

techstepgenr8tion wrote:
What I cobbled together so far for handling easy / beginner but doesn't get off the ground yet for intermediate or advanced:

https://stackblitz.com/edit/create-erer ... mponent.ts

For easy and intermediate I took Wildcat and Diabolical from here:

https://sandiway.arizona.edu/sudoku/examples.html

I'm interested in seeing if there are some puzzles out there on the edge of intermediate which might get stopped maybe a few more moves in or at least enough to give me some additional ideas for how I'd want to automate more heuristics.


I am looking at your TS code on stackblitz.com. I understand that TS is TypeScript and that TypeScript is "a strict syntactical superset of JavaScript and adds optional static typing to the language".

I have done some JavaScript coding, but I am finding the code a bit hard to follow. I think this is partly because if is event driven. It looks like your board, at the lowest level, is comprised of three groups of three rows, and each row is three integers. This cannot be right because each sudoku puzzle has 9x9 cells.

I see the first line logged in the console is "before while loop" which appears to be in
Code:
app/tools/app.components.ts:ngOnInit


Where is the initial set of hints?


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,403
Location: Pennsylvania

14 Nov 2022, 11:40 am

I discovered the puzzle I worked on years ago in my AI class is called the "15 Puzzle"

Wikipedia - 15 puzzle

The one that wbport mentioned as the "Triangle puzzle from Cracker Barrel" (I recall them at the Days Inn restaurants) is discussed here (with a simular attribution to Cracker Barrel):

JoeNord.com - Triangle Peg Game - All Solutions

And for sale here as "Tricky Triangle":

ChristianBook.com - Game On! Triangle Game (Tricky Triangle)

And for sale on eBay as "Vintage 1975 I.Q. Tester":

eBay - Vintage 1975 I.Q. Tester Wooden Triangle Brain Teaser


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


techstepgenr8tion
Veteran
Veteran

User avatar

Joined: 6 Feb 2005
Age: 44
Gender: Male
Posts: 24,148
Location: 28th Path of Tzaddi

14 Nov 2022, 11:53 am

Fenn wrote:
I am looking at your TS code on stackblitz.com. I understand that TS is TypeScript and that TypeScript is "a strict syntactical superset of JavaScript and adds optional static typing to the language".

I have done some JavaScript coding, but I am finding the code a bit hard to follow. I think this is partly because if is event driven. It looks like your board, at the lowest level, is comprised of three groups of three rows, and each row is three integers. This cannot be right because each sudoku puzzle has 9x9 cells.

The one I posted later in the thread (which solved Medium2) is cleaner - ie. I transitioned all of the location data into object properties:

https://stackblitz.com/edit/create-ahfd ... mponent.ts

^^ You'll see the manual patches between the lines 69 and 74 '// help' notes. Also I haven't had the chance to look at it more but I suspect that I need to do some troubleshooting on the 1 that I needed to insert in the middle grid at the top (it seems like my algorithm for comparing states of horizontal and vertical neighbors should have closed the bottom row).

This initial setup was more or less just getting a starting point of some type, figuring out the rules, and I realized that for adding more complex algorithms I was tripping over the complexity of having my objects mimicking the three-cell row sections. What I had previously to handle that scheme was 3 row groups and three column groups which is how that system was sorting out how the three property row sections would orient into a grid of nine cells. That got unwieldy when I wanted to do more complicated fills.

Fenn wrote:
I see the first line logged in the console is "before while loop" which appears to be in
Code:
app/tools/app.components.ts:ngOnInit

Yeah, here and there I'd have the try/catch kick something out and I couldn't always tell where it was exiting so I was using stuff like that to help orient myself. The good news with Angular in Stackblitz is I don't have the dreaded build time of several minutes between changes, it's relatively instantaneous which makes Stackblitz actually a great place to do proof of concept or learning / tinkering with things where I don't want to spend all day running builds.

The ngOnInit() is an Angular thing, effectively its a loading call and there's a complimentary onDestroy() that's used to terminate Subject, BehaviorSubject, and Observable subscriptions (you get data leaks / failed garbage collection if you don't close down). They also have some others like ngAfterViewInit() and ngAfterContentChecked() to grab other event hooks.

Fenn wrote:
Where is the initial set of hints?

I *think* the manual insertions are what you're talking about here (ie. 69 - 75), if not let me know.


_________________
“Love takes off the masks that we fear we cannot live without and know we cannot live within. I use the word "love" here not merely in the personal sense but as a state of being, or a state of grace - not in the infantile American sense of being made happy but in the tough and universal sense of quest and daring and growth.” - James Baldwin


Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,403
Location: Pennsylvania

14 Nov 2022, 1:18 pm

wbport wrote:
This is the Roche solver I tweaked a few years ago: RocheSudoku
I had to add a guess of 7 in the lower left corner for it to work.


I started looking at this. It took me a few tries to figure out how to use it.
I will make some usage notes here and then go back and look at the code.

Usage:
Initial screen (screen 1, "Puzzle Specification") allows creation of the (completely empty) grid, as the first of two steps to enter a puzzle from (for example) a puzzle book. The term "group" in this context is a, not necessarily square, subgrouping of cells. A 3x3 group will create a typical Sudoku puzzle with a 9x9 grid with "groups" of 3 cells by 3 cells, arranged in 3 groups by 3 groups. Form on the initial page is pre-filled with default values "Width" of 3 and "Height" of 3, and the Number of symbols is calculated by multiplying 3 times 3, and pre-filled with "123456789". This will give a typical Sudoku grid. Changing "Width" to "4" but leaving "Height" as 3, will give a number of symbols of 4 times 3 = 12, and will pre-fill the "Symbols" with a default value of "123456789ABC" (a Hexadecimal-like-notation). This will give an atypical Sudoku with groups of cells 4x3 = 12 cells (each 4 cells across and 3 cells down) arranged in 3 groups across and 4 groups down, for a square puzzle of 12 cells by 12 cells (with non-square groups).
The default symbols in the "Symbols" field may be replaced with other one-character symbols (each replacing one character in the original default set of symbols), for example the ABCDEFGHIJKL for a 4x3 puzzle. The number of symbols should remain the same as the automatically calculated default.
The "Grid Entry" button will generate and display the completely empty grid on a new page (screen 2, "Grid Entry"). A puzzle may be copied into the empty grid from a book by hand, or from https://www.sudokuoftheday.com/dailypuzzles and so on. The code does not generate its own puzzles from scratch. The "Solve" button on screen 2 will display screen 3 ("Solver").
The "About" button on screen 1 shows author (Warren Porter) and attribution of the original code which was forked (by Guyon Roche).
The source code may be seen (in Chrome on Mac OS) with Control-Click > View Page Source (or equivalent in other browsers / OSs - I think this is Right-Click > View Page Source for Chrome on Windows).
Screen 3 is the Solver. On the Solver screen the original puzzle with hints as keyed in and zero iterations of the solution executed is displayed at first.
The "Solve" button will display each iteration of the solution with a 1 second delay between screens, and stop when a solution or contradiction is reached.
The "Iterate" button will do one iteration of the solution then stop and wait for more user input.
The "Reset" button after "Solve" or "Iterate" will reset the board to just hints, like when the Solver screen first loaded.
The "Clear" button will clear the log off of the screen. Iterate and Solve log to the screen (the text will appear before the "Clear" button but after the other buttons and the grid).
The "Grid Entry" button lets you go back to the "Grid Entry" screen (Screen 2) and modify the set of hints with addition and deletions.
The "New Puzzle" button will take you back to the "Puzzle Specification" screen (Screen 1).


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,403
Location: Pennsylvania

14 Nov 2022, 2:16 pm

techstepgenr8tion wrote:
Fenn wrote:
Where is the initial set of hints?

I *think* the manual insertions are what you're talking about here (ie. 69 - 75), if not let me know.


I have only ever worked on sudoku as a solo pursuit so I guess I never learned the "correct terminology".

So I asked Doctor Google.

What I am thinking about is called "hints" in one book I have. Several web pages call them "givens" or "clues".

A "cell" is the smallest square in a Sudoko puzzle you might find in a Dell book. When the book is new some cells are already filled in and others are left blank for you to solve. A value written in a cell is called an "element". If you think a cell might have more than one value you might write in very small numbers intending to remind yourself which elements are possible and which are impossible (given the information you have at the time). The possible elements for the cell value are called "candidates". The "for sure" elements (cell values) printed in the book when get it are called "givens" or "clues".

In the book "Sudoku programming with C" by Giulio Zambon, "givens" or "clues" are also called "hints".

sudokuprimer.com - glossary

Wikipedia - Glossary of Sudoku

worldcat.org - Sudoku Programming with C
goodreads.com - Sudoku Programming with C


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


techstepgenr8tion
Veteran
Veteran

User avatar

Joined: 6 Feb 2005
Age: 44
Gender: Male
Posts: 24,148
Location: 28th Path of Tzaddi

14 Nov 2022, 5:29 pm

Fenn wrote:
In the book "Sudoku programming with C" by Giulio Zambon, "givens" or "clues" are also called "hints".

Ok, got it.

In both instances I have the givens / clues in the puzzles.ts under the tools folder:

Quote:
import { IPuzzle } from './iinternal';

export class Puzzles {
static SDKEasy: IPuzzle = {
name: 'Easy',
puzzle: [
{ row: [1, 0, 0, 4, 8, 9, 0, 0, 6], gi: [] },
{ row: [7, 3, 0, 0, 0, 0, 0, 4, 0], gi: [] },
{ row: [0, 0, 0, 0, 0, 1, 2, 9, 5], gi: [] },
{ row: [0, 0, 7, 1, 2, 0, 6, 0, 0], gi: [] },
{ row: [5, 0, 0, 7, 0, 3, 0, 0, 8], gi: [] },
{ row: [0, 0, 6, 0, 9, 5, 7, 0, 0], gi: [] },
{ row: [9, 1, 4, 6, 0, 0, 0, 0, 0], gi: [] },
{ row: [0, 2, 0, 0, 0, 0, 0, 3, 7], gi: [] },
{ row: [8, 0, 0, 5, 1, 2, 0, 0, 4], gi: [] },
],
};
static SDKMedium: IPuzzle = {
name: 'Medium',
puzzle: [
{ row: [0, 0, 0, 9, 0, 5, 0, 6, 0], gi: [] },
{ row: [1, 6, 0, 0, 0, 8, 0, 0, 0], gi: [] },
{ row: [0, 0, 0, 0, 4, 0, 0, 1, 3], gi: [] },
{ row: [0, 2, 0, 5, 0, 0, 8, 0, 0], gi: [] },
{ row: [7, 3, 9, 0, 8, 0, 0, 4, 5], gi: [] },
{ row: [0, 0, 8, 0, 0, 0, 2, 0, 9], gi: [] },
{ row: [3, 0, 0, 0, 7, 0, 0, 2, 0], gi: [] },
{ row: [0, 8, 2, 4, 5, 0, 3, 0, 7], gi: [] },
{ row: [9, 5, 0, 0, 0, 0, 0, 8, 0], gi: [] },
],
};
static SDKMedium2: IPuzzle = {
name: 'Medium2',
puzzle: [
{ row: [0, 9, 0, 1, 0, 0, 0, 7, 0], gi: [] },
{ row: [0, 0, 0, 0, 3, 0, 0, 8, 0], gi: [] },
{ row: [0, 5, 0, 8, 6, 2, 0, 3, 9], gi: [] },
{ row: [2, 0, 0, 0, 0, 6, 3, 9, 0], gi: [] },
{ row: [5, 0, 0, 0, 0, 0, 0, 0, 4], gi: [] },
{ row: [0, 6, 9, 2, 0, 0, 0, 0, 8], gi: [] },
{ row: [9, 7, 0, 6, 2, 8, 0, 5, 0], gi: [] },
{ row: [0, 2, 0, 0, 7, 0, 0, 0, 0], gi: [] },
{ row: [0, 8, 0, 0, 0, 4, 0, 2, 0], gi: [] },
],
};
static SDKIntermediate: IPuzzle = {
name: 'Intermediate',
puzzle: [
{ row: [0, 2, 0, 6, 0, 8, 0, 0, 0], gi: [] },
{ row: [5, 8, 0, 0, 0, 9, 7, 0, 0], gi: [] },
{ row: [0, 0, 0, 0, 4, 0, 0, 0, 0], gi: [] },
{ row: [3, 7, 0, 0, 0, 0, 5, 0, 0], gi: [] },
{ row: [6, 0, 0, 0, 0, 0, 0, 0, 4], gi: [] },
{ row: [0, 0, 8, 0, 0, 0, 0, 1, 3], gi: [] },
{ row: [0, 0, 0, 0, 2, 0, 0, 0, 0], gi: [] },
{ row: [0, 0, 9, 8, 0, 0, 0, 3, 6], gi: [] },
{ row: [0, 0, 0, 3, 0, 6, 0, 9, 0], gi: [] },
],
};
static SDKWPChallenge: IPuzzle = {
name: 'WPChallenge',
puzzle: [
{ row: [6, 0, 1, 0, 3, 0, 0, 0, 0], gi: [] },
{ row: [0, 0, 0, 0, 0, 4, 2, 6, 0], gi: [] },
{ row: [5, 0, 0, 6, 0, 0, 0, 0, 0], gi: [] },
{ row: [9, 1, 0, 0, 0, 0, 6, 0, 0], gi: [] },
{ row: [0, 0, 4, 3, 0, 7, 9, 0, 0], gi: [] },
{ row: [0, 0, 8, 0, 0, 0, 0, 4, 1], gi: [] },
{ row: [0, 0, 0, 0, 0, 3, 0, 0, 9], gi: [] },
{ row: [0, 9, 5, 7, 0, 0, 0, 0, 0], gi: [] },
{ row: [0, 0, 0, 0, 4, 0, 8, 0, 5], gi: [] },
],
};
}


_________________
“Love takes off the masks that we fear we cannot live without and know we cannot live within. I use the word "love" here not merely in the personal sense but as a state of being, or a state of grace - not in the infantile American sense of being made happy but in the tough and universal sense of quest and daring and growth.” - James Baldwin


wbport
Sea Gull
Sea Gull

User avatar

Joined: 16 Sep 2012
Gender: Male
Posts: 220

15 Nov 2022, 9:59 am

Fenn wrote:
wbport wrote:
This is the Roche solver I tweaked a few years ago: RocheSudoku
I had to add a guess of 7 in the lower left corner for it to work.


I started looking at this. It took me a few tries to figure out how to use it.
I will make some usage notes here and then go back and look at the code.



Thank you for your interest in this.

I will lose the website by Nov 28, so if you want it, download it now.



Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,403
Location: Pennsylvania

15 Nov 2022, 1:12 pm

wbport wrote:
Fenn wrote:
wbport wrote:
This is the Roche solver I tweaked a few years ago: RocheSudoku
I had to add a guess of 7 in the lower left corner for it to work.


I started looking at this. It took me a few tries to figure out how to use it.
I will make some usage notes here and then go back and look at the code.



Thank you for your interest in this.

I will lose the website by Nov 28, so if you want it, download it now.


Ok -
I tried making a copy of it here:

https://stackblitz.com/edit/create-d1cp ... index.html

But there is something I might have done wrong - it doesn't display. Maybe techstepgenr8tion can point out what I did wrong.

Also here:

https://github.com/fennellb/create-d1cpv7


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


wbport
Sea Gull
Sea Gull

User avatar

Joined: 16 Sep 2012
Gender: Male
Posts: 220

15 Nov 2022, 10:30 pm

The script on the last line is not needed, it is inserted by godaddy to provide cpanel tracking.

I had no problem opening it with my browser or having Notepad++ run it after I saved a change. Outside of a Javascript and later a CSS class, I've never tried to run it from codepen.



PhosphorusDecree
Veteran
Veteran

User avatar

Joined: 3 May 2016
Age: 43
Gender: Male
Posts: 3,404
Location: Yorkshire, UK

16 Nov 2022, 7:12 am

Over the years I've developed a sudoku technique that's strong enough for nearly all the sudoku puzzles I try - quite often now, the puzzles are too easy so I add restrictions to how I'm "allowed" to solve it. (Like "only consider 9X9 squares" or "only consider individual lines.") But I don't deal well with the tiny minority of puzzles where you have to guess. It comes up so rarely I've just never developed a decent notation for tracing the consequences of the guess. Particularly as the boxes are quite crowded with other notation by that point.


_________________
You're so vain
I bet you think this sig is about you