Whip solver in javascript

Programs which generate, solve, and analyze Sudoku puzzles

Whip solver in javascript

Postby Mauricio » Fri Sep 07, 2012 12:06 am

I just learned a bit of javascript and decided to translate my C code for whips, here is the result

http://156.17.86.3/~guest15/sudoku/whips.html

The puzzle has to be a string of length 81, with 0 as nongivens.

Comments are welcome.

Edit: Just checked and it works in Firefox 12(Windows), Chrome 21 (Windows), Safari 5.1.7 (Windows) but not in IE 9.
Last edited by Mauricio on Mon Sep 10, 2012 12:57 am, edited 1 time in total.
Mauricio
 
Posts: 1174
Joined: 22 March 2006

Re: Whip solver in javascript

Postby dobrichev » Sat Sep 08, 2012 8:51 pm

17" on my htc android
dobrichev
2016 Supporter
 
Posts: 1316
Joined: 24 May 2010

Re: Whip solver in javascript

Postby tarek » Sat Sep 08, 2012 10:54 pm

Time elapsed: 7.86 seconds on iPhone ios
User avatar
tarek
 
Posts: 2624
Joined: 05 January 2006

Re: Whip solver in javascript

Postby Mauricio » Mon Sep 10, 2012 8:01 am

I have translated more functions, now you can choose to solve between whips, braids, and nrc (discontinuous nice loops).

The following puzzle has a high rating and little calculation time
Code: Select all
000001002000030040005200100003600010020070008900005700009007000080900004300040080
Mauricio
 
Posts: 1174
Joined: 22 March 2006

Re: Whip solver in javascript

Postby denis_berthier » Sat Sep 15, 2012 3:05 pm

Mauricio wrote:I just learned a bit of javascript and decided to translate my C code for whips, here is the result


The computation times seem to be good.
Did you compute a mean js/C time ratio ?

As for the notation, you're missing the main point of the nrc notation: each {llc rlc} pair of candidates appearing in a chain can be factorised as 2D-cell{llc-value rlc-value}.
As shown in "Constraint Resolution Theories" (CRT), all the chain patterns I introduced in "The Hidden Logic of Sudoku" can be generalised to any (finite) Constraint Satisfaction Problem [If you don't have CRT, you can also find part of this on my website, in pdf versions of papers I published before it].
In this generalisation, the nrc notation for such pairs has a natural and straightforward extension as csp-variable{llc-value rlc-value}. [The 2D-cells appearing in the Extended Sudoku Board are graphical representations of its CSP-variables.]
As a result, splitting the rc, rn, cn or bn cells into two parts just for the sake of keeping the (n, r, c) order is meaningless.

I also noticed an inversion of llc and rlc in some {. something}.
denis_berthier
2010 Supporter
 
Posts: 1253
Joined: 19 June 2007
Location: Paris

Re: Whip solver in javascript

Postby Mauricio » Fri Sep 21, 2012 2:28 am

denis_berthier wrote:The computation times seem to be good.
Did you compute a mean js/C time ratio ?

Surprisingly, in chrome for windows, javascript is between 10% and 100% slower than my c implementation , depending on the puzzle.

denis_berthier wrote:I also noticed an inversion of llc and rlc in some {. something}.
That nonstandard notation means a single is found.


I have updated the solver, now it can also solve using gBraids, I propose as a test case the following puzzle, gB=6 and not even a single vanilla Braid can be applied.
Code: Select all
001002003000030040200500100004006001070000080100900700002007006050080000300200900
Mauricio
 
Posts: 1174
Joined: 22 March 2006

Solving a puzle

Postby JC Van Hay » Fri Sep 21, 2012 8:36 am

Mauricio wrote:
Code: Select all
001002003000030040200500100004006001070000080100900700002007006050080000300200900

I enjoyed solving this interesting puzzle in the following way ...
From any one of the 2 weakly coupled Kites 1R8C5 and 2R5C8 forming a loop[4] :

    Kite(1r5c5=1r79c5-1r8c46=1r8c8)-Kite(2r8c8=2r46c8-2r5c79=2r5c5) @ :=> -1r7c4.r9c6,-37r8c8,-2r4c7.2r6c9,-45r5c5
and percolating through the puzzle using only Locked Candidates and Locked Subsets,

    r5c5=1<->r8c8=2;NP(34)r57c4;+[3r5c4 or 4r5c4]->contradiction
    OR
    r8c8=1<->r5c5=2;NP(45)R6c59;+[4r6c5->solution or 5r6c5->contradiction]
But this solution is may be off topic :-)
JC Van Hay
 
Posts: 716
Joined: 22 May 2010


Return to Software

cron