BASIC program description; uses interprested GWBASIC

Programs which generate, solve, and analyze Sudoku puzzles

BASIC program description; uses interprested GWBASIC

Postby JWM » Thu Sep 22, 2005 3:09 am

Hello,

I developed a program using interpreted GWBASIC {tm} to solve
all grids I submitted to it so far. Average run time is 1/2 second,
mostly for recursive processing. The 20-year-old interpreter,
originally supplied with the IBM PC {tm} series, uses line numbers
unlike many much newer dialects.

Program uses several 9x9 arrays to build strings of 27 characters
at a time: the digits and '-' for unused cells. The 27 is from the
9+9+9 for each row/column/box.

Process then checks substrings to count occurrences of digits and
'analyzes' intersections of each row/column/box in turn, checking
for all candidates and listing separate report of 'must have' digits.

Report uses each partically-filled grid as the input data file for the
next iteration, hence the recursive aspect. Some 'passes' thru these
loops result in 2 or 3 digits being added; other times, especially in the
puzzles rated "easy", program detects up to 20 digits that can be
filled in straightaway.

Report shows the intermediate steps and lists all unused digits as
a string, showing string length shrinking to zero. A 'setup' procedure
validates the initial grid to ensure no conflicts and duplicate digits
can ever 'sneak in', and processes use extensive error-trapping.

-John Morse

Albany NY

9-21-2005 11:11pm EDT
JWM
 
Posts: 1
Joined: 21 September 2005

Return to Software