🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.buddha.short.fat.guy
16 messages
16 total messages Started by "Ned Ludd" Fri, 29 Jun 2007 15:04
test ignort
#247485
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 15:04
831 lines
18550 bytes
Please ignore this - I'm just parking this here. - Ned


REM  Program SUDOKUX
REM  9/06 Ned Ludd

DIM endposs(50, 2)

CLEAR , , 2000

CLS

ulc$ = CHR$(201): urc$ = CHR$(187): llc$ = CHR$(200): lrc$ = CHR$(188)
lin1$ = CHR$(196): lin2$ = CHR$(205): lin2a$ = CHR$(209)
lin2b$ = CHR$(203): lin2au$ = CHR$(207): lin2bu$ = CHR$(202)
le1$ = CHR$(199): le2$ = CHR$(204): re1$ = CHR$(182): re2$ = CHR$(185)
bar1$ = CHR$(179): bar2$ = CHR$(186)

tmp1$ = "   " + bar1$ + "   " + bar1$ + "   " + bar2$
typ1$ = bar2$ + tmp1$ + tmp1$ + "   " + bar1$ + "   " + bar1$ + "   " +
bar2$

tmp1$ = lin1$ + lin1$ + lin1$ + CHR$(197)
tmp2$ = lin1$ + lin1$ + lin1$ + CHR$(215)
typ2$ = le1$ + tmp1$ + tmp1$ + tmp2$ + tmp1$ + tmp1$ + tmp2$
typ2$ = typ2$ + tmp1$ + tmp1$ + lin1$ + lin1$ + lin1$ + re1$

tmp1$ = lin2$ + lin2$ + lin2$ + CHR$(216)
tmp2$ = lin2$ + lin2$ + lin2$ + CHR$(206)
typ3$ = le2$ + tmp1$ + tmp1$ + tmp2$ + tmp1$ + tmp1$ + tmp2$
typ3$ = typ3$ + tmp1$ + tmp1$ + lin2$ + lin2$ + lin2$ + re2$

gridlin0$ = "-------------------------------------"
gridlin1$ = "|-----------+-----------+-----------|"
gridlin2$ = "|---|---|---|---|---|---|---|---|---|"

REM  Check for a prior saved file:

ON ERROR GOTO MAINMENU
OPEN "sudokux.txt" FOR INPUT AS #1

ON ERROR GOTO FILEERROR
LINE INPUT #1, line1$
LINE INPUT #1, LINE2$

PRINT
PRINT
PRINT "There is a prior file available from: "; LINE2$
PRINT
INPUT "Would you like to start with this file? (Y/N): ", tst$
tst$ = UCASE$(LEFT$(tst$, 1))
IF tst$ <> "Y" THEN
  CLOSE #1
  GOTO MAINMENU
END IF

LINE INPUT #1, LINE2$
nonnum = 0
FOR i = 1 TO 9
  LINE INPUT #1, LINE2$
  LINE INPUT #1, LINE2$
  LINE2$ = " " + LINE2$
  FOR j = 1 TO 9
    tst$ = MID$(LINE2$, (((j - 1) * 4) + 4), 1)
    IF (tst$ < "1" OR tst$ > "9") AND tst$ <> " " THEN
        nonnum = 1
      ELSE
        grid(i, j) = VAL(tst$)
    END IF
  NEXT j
NEXT i
CLOSE #1

IF nonnum > 0 THEN
  PRINT
  PRINT "An error was detected in the saved file."
  PRINT "Please enter a new starting grid."
  PRINT
  INPUT "Press enter.", tst$
  GOTO MAINMENU
END IF

GOTO MAINEDIT

FILEERROR:
CLOSE
PRINT
PRINT "There was an error reading the SUDOKUX.TXT file."
PRINT
INPUT "Press enter for main menu.", tst$

MAINMENU:

rcnt = 1
DO WHILE (rcnt > 0)

CLS
GOSUB PRINTGRID

IF rcnt = 1 THEN
  LOCATE 21, 1
  PRINT "Enter each Row of starting numbers, indicating blank cells with"
  PRINT "either a blank or a zero. (You will be allowed to edit later.)"
  PRINT
 ELSE
  LOCATE 22, 1
END IF

PRINT "Enter row"; rcnt;
LINE INPUT ": ", tst$

IF LEN(tst$) <> 9 THEN
  IF LEN(tst$) > 9 THEN
    PRINT "String > 9 char. long - You will be allowed to edit later."
    INPUT "Press Enter to continue.", tst2$
  END IF
  tst$ = tst$ + "         "
END IF

FOR i = 1 TO 9
  dig$ = MID$(tst$, i, 1)
  IF (dig$ >= "0" AND dig$ <= "9") OR dig$ = " " THEN
      grid(rcnt, i) = VAL(dig$)
    ELSE
      PRINT "Non-digit in col "; i; "- You will be allowed to edit later."
      grid(rcnt, i) = 0
      INPUT "Press Enter to continue.", tst2$
  END IF
NEXT i

rcnt = rcnt + 1
IF rcnt > 9 THEN rcnt = 0

LOOP

MAINEDIT:

REM  Display finished grid and edit if necessary:

editflg = 1
DO WHILE (editflg = 1)

 CLS
 GOSUB PRINTGRID
 LOCATE 22, 1

 REM  Test 2 basic rules - rows/columns & sections:

 errflg1 = 0
 FOR i = 1 TO 9
   FOR j = 1 TO 9
     tstdig = grid(i, j)
     FOR k = 1 TO 9
       IF tstdig > 0 THEN
         IF tstdig = grid(i, k) AND k <> j AND errflg1 = 0 THEN
           PRINT "There are two "; tstdig; "'s in row "; i; "- please edit."
           errflg1 = 1
         END IF
       END IF
     NEXT k
   NEXT j
 NEXT i

 errflg2 = 0
 FOR i = 1 TO 9
   FOR j = 1 TO 9
     tstdig = grid(j, i)
     FOR k = 1 TO 9
       IF tstdig > 0 THEN
         IF tstdig = grid(k, i) AND k <> j AND errflg2 = 0 THEN
           PRINT "There are two "; tstdig; "'s in col. "; i; "- please
edit."
           errflg2 = 1
         END IF
       END IF
     NEXT k
   NEXT j
 NEXT i

 errflg3 = 0
 FOR i = 1 TO 3
   FOR j = 1 TO 3
     begr = ((i - 1) * 3) + 1
     begc = ((j - 1) * 3) + 1
     k = 0
     FOR m = 1 TO 3
       FOR n = 1 TO 3
         k = k + 1
         tstsec(k) = grid((begr - 1) + m, (begc - 1) + n)
       NEXT n
     NEXT m
     FOR m = 1 TO 9
       FOR n = 1 TO 9
         IF tstsec(n) > 0 THEN
           IF tstsec(n) = tstsec(m) AND m <> n AND errflg3 = 0 THEN
             IF i = 1 THEN sec2$ = "upper"
             IF i = 2 THEN sec2$ = "middle"
             IF i = 3 THEN sec2$ = "lower"
             IF j = 1 THEN sec1$ = "left"
             IF j = 2 THEN sec1$ = "center"
             IF j = 3 THEN sec1$ = "right"
             PRINT "There are two "; tstsec(n); "'s in the ";
             PRINT sec2$; " "; sec1$; " section - please edit."
             errflg3 = 1
           END IF
         END IF
       NEXT n
     NEXT m
   NEXT j
 NEXT i

 IF (errflg1 + errflg2 + errflg3) = 0 THEN PRINT "No errors.": PRINT

 INPUT "Do you wish to edit? (Y/N)"; tst$
 tst$ = UCASE$(LEFT$(tst$, 1))

 IF ((errflg1 + errflg2 + errflg3) > 0) AND tst$ <> "Y" THEN
   PRINT
   PRINT "Bye!"
   PRINT
   INPUT "Press Enter.", tst$
   SYSTEM
   END
 END IF

 IF tst$ <> "Y" THEN editflg = 0

 IF editflg = 1 THEN
   done = 0
   DO WHILE (done = 0)
     CLS
     GOSUB PRINTGRID
     LOCATE 22, 1

     tst$ = "~"
     DO WHILE ((tst$ < "1" OR tst$ > "9") AND tst$ <> " ")
       LINE INPUT "Enter Row # to re-enter (1-9) [End=Enter]: ", tst$
       IF LEN(tst$) > 1 THEN tst$ = "0"
       tst$ = tst$ + " "
       tst$ = LEFT$(tst$, 1)
     LOOP

     IF tst$ = " " THEN done = 1

     IF done = 0 THEN
       rcnt = VAL(tst$)
       PRINT "Enter new row"; rcnt;
       LINE INPUT ": ", tst$
       tst$ = tst$ + "         "

       FOR i = 1 TO 9
         dig$ = MID$(tst$, i, 1)
         IF (dig$ >= "0" AND dig$ <= "9") OR dig$ = " " THEN
             grid(rcnt, i) = VAL(dig$)
           ELSE
             PRINT "Non-digit in col "; i; "."
             grid(rcnt, i) = 0
             INPUT "Press Enter to continue.", tst2$
         END IF
       NEXT i
     END IF
   LOOP
 END IF
LOOP

REM  Save copy of begin grid as SUDOKUX.TXT:

OPEN "SUDOKUX.TXT" FOR OUTPUT AS #1

PRINT #1, "SUDOKUX.TXT"
PRINT #1, DATE$; " "; LEFT$(TIME$, 5)
PRINT #1, " "
PRINT #1, gridlin0$

FOR i = 1 TO 9: PRINT #1, "|";
  pstr1$ = ""
  FOR j = 1 TO 3
    p1$ = "  "
    IF grid(i, (j - 1) * 3 + 1) > 0 THEN p1$ = STR$(grid(i, (j - 1) * 3 +
1))
    p2$ = "  "
    IF grid(i, (j - 1) * 3 + 2) > 0 THEN p2$ = STR$(grid(i, (j - 1) * 3 +
2))
    p3$ = "  "
    IF grid(i, (j - 1) * 3 + 3) > 0 THEN p3$ = STR$(grid(i, (j - 1) * 3 +
3))
    pstr1$ = p1$ + " |" + p2$ + " |" + p3$ + " |"
    PRINT #1, pstr1$;
  NEXT j: PRINT #1,
  IF i = 3 OR i = 6 THEN
       PRINT #1, gridlin1$
    ELSE
       IF i = 9 THEN
           PRINT #1, gridlin0$
         ELSE
           PRINT #1, gridlin2$
       END IF
  END IF
NEXT i

CLOSE #1

INPUT "Ready to go... Press Enter to solve. ", tst$

CLS
GOSUB PRINTGRID
LOCATE 21, 1

REM  Load POSS grid with possible switches (elements 1-9) = 1;
REM  if GRID cell is solved, set zero element to solved value.

found = 0
FOR i = 1 TO 9
  FOR j = 1 TO 9
    IF grid(i, j) <> 0 THEN
        poss(i, j, 0) = grid(i, j)
        found = found + 1
      ELSE
        FOR k = 1 TO 9
          poss(i, j, k) = 1
        NEXT k
    END IF
  NEXT j
NEXT i

GOSUB SWITCHOFF


REM  SOLUTION SECTION:        * * * * * * * * * * * * *

SOLVEIT:

solving = 1
DO WHILE (solving = 1)

REM  Check all open cells' possibles for only one left:

FOR i = 1 TO 9
  FOR j = 1 TO 9
    IF grid(i, j) = 0 THEN
      totpos = 0
      FOR k = 1 TO 9
        IF poss(i, j, k) <> 0 THEN
          totpos = totpos + 1
          lastval = k
        END IF
      NEXT k
      IF totpos = 1 THEN
        poss(i, j, 0) = lastval
        grid(i, j) = lastval
        found = found + 1
        LOCATE ((i - 1) * 2) + 3, ((j - 1) * 4) + 2
        dig$ = STR$(grid(i, j))
        PRINT dig$;
        LOCATE 22, 1
        PRINT "Found: "; found
      END IF
    END IF
  NEXT j
NEXT i

GOSUB SWITCHOFF

REM  Check every row, column, section for a cell containing the
REM  only possible number available for that row, col, section:

FOR i = 1 TO 9  'Rows:
  FOR j = 1 TO 9: tot9(j) = 0: NEXT j
  FOR j = 1 TO 9
    IF grid(i, j) = 0 THEN
      FOR k = 1 TO 9
        IF poss(i, j, k) > 0 THEN tot9(k) = tot9(k) + 1
      NEXT k
    END IF
  NEXT j

  FOR j = 1 TO 9
    IF tot9(j) = 1 THEN  ' Single possible found:
      foundval = 0
      DO WHILE (foundval = 0)
        FOR k = 1 TO 9
          IF grid(i, k) = 0 AND poss(i, k, j) = 1 THEN
            foundval = k
          END IF
        NEXT k
        IF foundval = 0 THEN
          foundval = j
          IF endtest = 0 THEN GOSUB BADEND
          found = -100
        END IF
      LOOP
      grid(i, foundval) = j
      found = found + 1
      LOCATE ((i - 1) * 2) + 3, ((foundval - 1) * 4) + 2
      dig$ = STR$(j)
      PRINT dig$;
      LOCATE 22, 1
      PRINT "Found: "; found
    END IF
  NEXT j
NEXT i

GOSUB SWITCHOFF

FOR j = 1 TO 9 'Columns:
  FOR i = 1 TO 9: tot9(i) = 0: NEXT i
  FOR i = 1 TO 9
    IF grid(i, j) = 0 THEN
      FOR k = 1 TO 9
        IF poss(i, j, k) > 0 THEN tot9(k) = tot9(k) + 1
      NEXT k
    END IF
  NEXT i
  FOR i = 1 TO 9
    IF tot9(i) = 1 THEN
      foundval = 0
      DO WHILE (foundval = 0)
        FOR k = 1 TO 9
          IF grid(k, j) = 0 AND poss(k, j, i) = 1 THEN
            foundval = k
          END IF
        NEXT k
        IF foundval = 0 THEN
          foundval = i
          IF endtest = 0 THEN GOSUB BADEND
          found = -100
        END IF
      LOOP
      grid(foundval, j) = i
      found = found + 1
      LOCATE ((foundval - 1) * 2) + 3, ((j - 1) * 4) + 2
      dig$ = STR$(i)
      PRINT dig$;
      LOCATE 22, 1
      PRINT "Found: "; found
    END IF
  NEXT i
NEXT j

GOSUB SWITCHOFF

FOR ii = 1 TO 3  ' Sections:
  FOR jj = 1 TO 3
    begr = ((ii - 1) * 3) + 1
    begc = ((jj - 1) * 3) + 1
    kk = 0
    FOR mm = 1 TO 3  ' Set up section as a 'row' for testing:
      FOR nn = 1 TO 3
        kk = kk + 1
        tstgrid(kk) = grid((begr - 1) + mm, (begc - 1) + nn)
        FOR k = 1 TO 9
          tstposs(kk, k) = poss((begr - 1) + mm, (begc - 1) + nn, k)
        NEXT k
      NEXT nn
    NEXT mm
    FOR i = 1 TO 9: tot9(i) = 0: NEXT i
    FOR i = 1 TO 9
      IF tstgrid(i) = 0 THEN
        FOR k = 1 TO 9
          IF tstposs(i, k) > 0 THEN tot9(k) = tot9(k) + 1
        NEXT k
      END IF
    NEXT i
    FOR i = 1 TO 9
      IF tot9(i) = 1 THEN
        foundval = 0
        DO WHILE (foundval = 0)
          FOR k = 1 TO 9
            IF tstgrid(k) = 0 AND tstposs(k, i) = 1 THEN
              foundval = k
            END IF
          NEXT k
          IF foundval = 0 THEN
            foundval = i
            IF endtest = 0 THEN GOSUB BADEND
            found = -100
          END IF
        LOOP
        IF foundval >= 1 AND foundval <= 3 THEN
          rowpos = begr
          colpos = begc - 1 + foundval
        END IF
        IF foundval >= 4 AND foundval <= 6 THEN
          rowpos = begr + 1
          colpos = begc - 4 + foundval
        END IF
        IF foundval >= 7 AND foundval <= 9 THEN
          rowpos = begr + 2
          colpos = begc - 7 + foundval
        END IF
        grid(rowpos, colpos) = i
        found = found + 1
        LOCATE ((rowpos - 1) * 2) + 3, ((colpos - 1) * 4) + 2
        dig$ = STR$(i)
        PRINT dig$;
        LOCATE 22, 1
        PRINT "Found: "; found
      END IF
    NEXT i
  NEXT jj
NEXT ii

GOSUB SWITCHOFF

IF found >= 81 THEN solving = 0
IF found = lastfound THEN solving = 0
IF found < 1 THEN solving = 0

IF solving = 1 THEN  ' Test for any cell with no possibles:
  noposs = 0
  FOR i = 1 TO 9
    FOR j = 1 TO 9
      IF grid(i, j) = 0 THEN
        tot9cnt = 0
        FOR k = 1 TO 9
          tot9cnt = tot9cnt + poss(i, j, k)
        NEXT k
        IF tot9cnt = 0 THEN noposs = 1
      END IF
    NEXT j
  NEXT i
END IF
IF noposs = 1 THEN solving = 0

IF solving = 1 THEN  ' Test for any double occurrences of same number:
 errflg1 = 0
 FOR i = 1 TO 9  ' Rows:
   FOR j = 1 TO 9
     tstdig = grid(i, j)
     FOR k = 1 TO 9
       IF tstdig > 0 THEN
         IF tstdig = grid(i, k) AND k <> j AND errflg1 = 0 THEN
           errflg1 = 1
         END IF
       END IF
     NEXT k
   NEXT j
 NEXT i

 errflg2 = 0
 FOR i = 1 TO 9  ' Columns:
   FOR j = 1 TO 9
     tstdig = grid(j, i)
     FOR k = 1 TO 9
       IF tstdig > 0 THEN
         IF tstdig = grid(k, i) AND k <> j AND errflg2 = 0 THEN
           errflg2 = 1
         END IF
       END IF
     NEXT k
   NEXT j
 NEXT i

 errflg3 = 0
 FOR i = 1 TO 3  ' Sections:
   FOR j = 1 TO 3
     begr = ((i - 1) * 3) + 1
     begc = ((j - 1) * 3) + 1
     k = 0
     FOR m = 1 TO 3
       FOR n = 1 TO 3
         k = k + 1
         tstsec(k) = grid((begr - 1) + m, (begc - 1) + n)
       NEXT n
     NEXT m
     FOR m = 1 TO 9
       FOR n = 1 TO 9
         IF tstsec(n) > 0 THEN
           IF tstsec(n) = tstsec(m) AND m <> n AND errflg3 = 0 THEN
             errflg3 = 1
           END IF
         END IF
       NEXT n
     NEXT m
   NEXT j
 NEXT i
END IF
IF (errflg1 + errflg2 + errflg3) <> 0 THEN solving = 0

lastfound = found

LOOP

IF found = 81 THEN GOTO ENDTANDE

IF found < 81 THEN  ' Trial-and-error section:
  IF endtest = 0 THEN
    endposstot = 0
    FOR i = 1 TO 9
      FOR j = 1 TO 9
        IF grid(i, j) = 0 THEN
          IF endposstot < 50 THEN
                endposstot = endposstot + 1
                endposs(endposstot, 1) = i
                endposs(endposstot, 2) = j
          END IF
        END IF
      NEXT j
    NEXT i
    savefound = found
    FOR i = 1 TO 9  ' Save the grid and possibles:
      FOR j = 1 TO 9
          savegrid(i, j) = grid(i, j)
      NEXT j
    NEXT i
    FOR i = 1 TO 9
      FOR j = 1 TO 9
        FOR k = 1 TO 9
          saveposs(i, j, k) = poss(i, j, k)
        NEXT k
      NEXT j
    NEXT i
  END IF

  IF endtest > 0 THEN  ' Restore grid and possibles:
    found = savefound
    lastfound = found
    FOR i = 1 TO 9
      FOR j = 1 TO 9
          grid(i, j) = savegrid(i, j)
      NEXT j
    NEXT i
    FOR i = 1 TO 9
      FOR j = 1 TO 9
        FOR k = 1 TO 9
          poss(i, j, k) = saveposs(i, j, k)
        NEXT k
      NEXT j
    NEXT i
    CLS
    GOSUB PRINTGRID
  END IF

  IF cellcnt >= celltot THEN celltot = 0

  IF celltot = 0 THEN
    cellcnt = 0
    endtest = endtest + 1
    IF endtest <= endposstot THEN  ' Get next set of test possibles:
      testrow = endposs(endtest, 1)
      testcoll = endposs(endtest, 2)
      celltot = 0
      FOR m = 1 TO 9
        IF poss(testrow, testcoll, m) <> 0 THEN
          celltot = celltot + 1
          celltest(celltot) = m
        END IF
      NEXT m
    END IF
  END IF
END IF

IF celltot = 0 THEN GOTO ENDTANDE

cellcnt = cellcnt + 1
found = found + 1
lastfound = found
trycount = trycount + 1
grid(testrow, testcoll) = celltest(cellcnt)

LOCATE ((testrow - 1) * 2) + 3, ((testcoll - 1) * 4) + 2
dig$ = STR$(celltest(cellcnt))
PRINT dig$;
LOCATE 22, 1
PRINT "Found: "; found

GOTO SOLVEIT

ENDTANDE:

REM  Append copy of ending grid to SUDOKUX.TXT:

OPEN "SUDOKUX.TXT" FOR APPEND AS #1

PRINT #1, " "
PRINT #1, " "
PRINT #1, gridlin0$

FOR i = 1 TO 9: PRINT #1, "|";
  pstr1$ = ""
  FOR j = 1 TO 3
    p1$ = "  "
    IF grid(i, (j - 1) * 3 + 1) > 0 THEN p1$ = STR$(grid(i, (j - 1) * 3 +
1))
    p2$ = "  "
    IF grid(i, (j - 1) * 3 + 2) > 0 THEN p2$ = STR$(grid(i, (j - 1) * 3 +
2))
    p3$ = "  "
    IF grid(i, (j - 1) * 3 + 3) > 0 THEN p3$ = STR$(grid(i, (j - 1) * 3 +
3))
    pstr1$ = p1$ + " |" + p2$ + " |" + p3$ + " |"
    PRINT #1, pstr1$;
  NEXT j: PRINT #1,
  IF i = 3 OR i = 6 THEN
       PRINT #1, gridlin1$
    ELSE
       IF i = 9 THEN
           PRINT #1, gridlin0$
         ELSE
           PRINT #1, gridlin2$
       END IF
  END IF
NEXT i

CLOSE #1

IF found = 81 THEN
    PRINT "Done."
  ELSE
    LOCATE 22, 1
    PRINT "Found: "; found
    PRINT "I can't solve this."
END IF
PRINT "Beginning and ending grids are in SUDOKUX.TXT.";
PRINT "  Cells:"; endtest; " Tests:"; trycount
INPUT "Copyright 2006, Ned Ludd.  Press Enter.", tst$

SYSTEM

END  ' End of program. * * * * * * *


PRINTGRID:

 PRINT
 REM print top line:
 PRINT ulc$;
 FOR i = 1 TO 35
   lin$ = lin2$
   IF (i MOD 4) = 0 THEN lin$ = lin2a$
   IF (i MOD 12) = 0 THEN lin$ = lin2b$
   PRINT lin$;
 NEXT i: PRINT urc$

 REM print intermediate lines:
 PRINT typ1$: PRINT typ2$: PRINT typ1$: PRINT typ2$: PRINT typ1$: PRINT
typ3$
 PRINT typ1$: PRINT typ2$: PRINT typ1$: PRINT typ2$: PRINT typ1$: PRINT
typ3$
 PRINT typ1$: PRINT typ2$: PRINT typ1$: PRINT typ2$: PRINT typ1$

 REM print bottom line:
 PRINT llc$;
 FOR i = 1 TO 35
   lin$ = lin2$
   IF (i MOD 4) = 0 THEN lin$ = lin2au$
   IF (i MOD 12) = 0 THEN lin$ = lin2bu$
   PRINT lin$;
 NEXT i: PRINT lrc$

 FOR i = 1 TO 9
     FOR j = 1 TO 9
       IF grid(i, j) <> 0 THEN
         LOCATE ((i - 1) * 2) + 3, ((j - 1) * 4) + 2
         dig$ = STR$(grid(i, j))
         PRINT dig$;
       END IF
     NEXT j
 NEXT i

RETURN


SWITCHOFF:

REM  Turn off all POSS switches in each cell's row, column,
REM  and section for all solved cells in GRID.

FOR i = 1 TO 9
  FOR j = 1 TO 9
    IF grid(i, j) > 0 THEN
      FOR k = 1 TO 9  'Row possibles:
        IF poss(i, k, grid(i, j)) <> 0 THEN
          IF k <> j THEN poss(i, k, grid(i, j)) = 0
        END IF
      NEXT k
      FOR k = 1 TO 9  'Column possibles:
        IF poss(k, j, grid(i, j)) <> 0 THEN
          IF k <> i THEN poss(k, j, grid(i, j)) = 0
        END IF
      NEXT k

      IF i >= 1 AND i <= 3 THEN  'Section possibles:
        begr = 1
        endr = 3
      END IF
      IF i >= 4 AND i <= 6 THEN
        begr = 4
        endr = 6
      END IF
      IF i >= 7 AND i <= 9 THEN
        begr = 7
        endr = 9
      END IF
      IF j >= 1 AND j <= 3 THEN
        begc = 1
        endc = 3
      END IF
      IF j >= 4 AND j <= 6 THEN
        begc = 4
        endc = 6
      END IF
      IF j >= 7 AND j <= 9 THEN
        begc = 7
        endc = 9
      END IF
      FOR k = begr TO endr
        FOR m = begc TO endc
          IF poss(k, m, grid(i, j)) <> 0 THEN
            IF (k <> i AND m <> j) THEN poss(k, m, grid(i, j)) = 0
          END IF
        NEXT m
      NEXT k
    END IF
  NEXT j
NEXT i

RETURN


BADEND:
  LOCATE 23, 1
  PRINT "I can't solve this - Possible set-up problem with grid.  (";
foundval; ")"
  PRINT "Beginning grid is in SUDOKUX.TXT."
  INPUT "Copyright 2006, Ned Ludd.  Press Enter.", tst$
  SYSTEM
  END
RETURN


Re: test ignort
#247492
Author: Pete
Date: Fri, 29 Jun 2007 08:29
3 lines
94 bytes
If that's the holy grail of retirement, shoot me now.

Pete (insert winking emoticon here...)
Re: test ignort
#247505
Author: "Edgar"
Date: Fri, 29 Jun 2007 10:07
42 lines
1503 bytes
"Ned Ludd" <nedludd@ix.netcom.com> wrote in message
news:Cxahi.2142$zA4.1444@newsread3.news.pas.earthlink.net...
>
> "Pete" <eldupree@cox.net> wrote in message
> news:xz9hi.456304$g24.67293@newsfe12.phx...
>>
>> If that's the holy grail of retirement, shoot me now.
>> Pete (insert winking emoticon here...)
>>
>
>  Ha.  That's a keeper!
>
>                                                  Ned
>
> (It was a spasm six months ago.  I'd been retired for five
> months and hadn't written any code, and it just kind of
> spurted out.  I personally HATE sudoku puzzles, and have
> only done three ever, but the challenge was interesting.
> Not like the world needs another sudoku-solver - there
> are TONS of them on the net.  And I learned some neat and
> strange things about sudoku puzzles.)
>
>

I've been playing a kind of visual version of Sodoku on my phone lately
which I really like (like you I hate sodoku puzzles).  Basically you got a
20 by 20 grid, and along each row and column, there are numbers like 5,3,1,1
which means in this column, there are 5 pixels in a row, then some kind of
space, then 3 in a row, then some space, then 1 and the 1 again.  So you
have to make the picture based on these numbers along each row and column.
You start with the columns that have 0 or 20, then move on to 19 (of which
you know where 18 of those will have to go) and so on and little by little
you get a picture.

--
Edgar



--
Posted via a free Usenet account from http://www.teranews.com

Re: test ignort
#247496
Author: dt
Date: Fri, 29 Jun 2007 10:58
7 lines
124 bytes
Ned Ludd wrote:

> Please ignore this - I'm just parking this here. - Ned

Usenet as file storage?  Interesting concept.

T
Re: test ignort
#247507
Author: Keynes
Date: Fri, 29 Jun 2007 12:17
41 lines
1282 bytes
On Fri, 29 Jun 2007 16:35:46 GMT, "Ned Ludd" <nedludd@ix.netcom.com> wrote:

>
>"Pete" <eldupree@cox.net> wrote in message
>news:xz9hi.456304$g24.67293@newsfe12.phx...
>>
>> If that's the holy grail of retirement, shoot me now.
>> Pete (insert winking emoticon here...)
>>
>
>  Ha.  That's a keeper!
>
>                                                  Ned
>
>(It was a spasm six months ago.  I'd been retired for five
> months and hadn't written any code, and it just kind of
> spurted out.  I personally HATE sudoku puzzles, and have
> only done three ever, but the challenge was interesting.
> Not like the world needs another sudoku-solver - there
> are TONS of them on the net.  And I learned some neat and
> strange things about sudoku puzzles.)
>

It was a romance made somewhere or other to
see my first love (basic) still good for something
for nothing.

I'm the same way with games.  I don't play em
but I used to love to program them.  I've done
a bunch - yatsee, poker, blackjack, 3d othello,
and an open ended 3d shooter (unfortunately
before it's time, namely Grand Theft Auto.
Before that folks wanted to walk the same path
from start to finish, and brag about it.  3d engine
behind the curve, unfortunately.)

Noodle code RoolZ.
(OK, I exaggerate as usual.)



Re: test ignort
#247530
Author: Ben
Date: Fri, 29 Jun 2007 15:10
34 lines
803 bytes
Ned Ludd wrote:

> "Ben" <eggplantontoast@yahoo.co.uk> wrote in message
> news:46854a92$0$4737$4c368faf@roadrunner.com...
>
>>>>Ned Ludd wrote:
>>>>
>>>>>Please ignore this - I'm just parking this here. - Ned
>>>>
>>>>Usenet as file storage?  Interesting concept.
>>>>T
>>>
>>>Been doin' it for years.  (What do you think, I LIKE it here?)
>>>Ned
>>
>>Of course if you made the subject line something like "sudoko puzzle
>>from june 07" it might be easier to find later.
>>
>
>
>   Mmmm... I think searching for the text SUDOKUX.BAS would
> pretty much nail it.
>
>                                                        Ned
>
>
>
Probably.  But I would forget what text I thought I would remember when
I was looking for it again.

So I make sure one of my top three guesses will be correct.



Re: test ignort
#247536
Author: Ben
Date: Fri, 29 Jun 2007 15:19
39 lines
1092 bytes
Ned Ludd wrote:

> "Ben" <eggplantontoast@yahoo.co.uk> wrote in message
> news:46855933$0$4937$4c368faf@roadrunner.com...
>
>>>>>>Usenet as file storage?  Interesting concept.
>>>>>>T
>>>>>
>>>>>Been doin' it for years.  (What do you think, I LIKE it here?)
>>>>>Ned
>>>>
>>>>Of course if you made the subject line something like "sudoko puzzle
>>>>from june 07" it might be easier to find later.
>>>
>>>Mmmm... I think searching for the text SUDOKUX.BAS would
>>>pretty much nail it.
>>>Ned
>>
>>Probably.  But I would forget what text I thought I would remember when
>>I was looking for it again.
>>So I make sure one of my top three guesses will be correct.
>>
>
>
>   Oh, that's right... you're a Mac user.
>
>                                                       Ned
>
>
It's definitely made me lazy.  And less cautious about where I put things.

I can't imagine growing up that way.

Soon, I'll have tags in all my personal belongings, so when I get out of
bed in the morning, and I can't find my glasses, I'll pull out my
i-phone and type "glasses" into the serach box.

Ben

Re: test ignort
#247499
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 16:35
21 lines
658 bytes
"Pete" <eldupree@cox.net> wrote in message
news:xz9hi.456304$g24.67293@newsfe12.phx...
>
> If that's the holy grail of retirement, shoot me now.
> Pete (insert winking emoticon here...)
>

  Ha.  That's a keeper!

                                                  Ned

(It was a spasm six months ago.  I'd been retired for five
 months and hadn't written any code, and it just kind of
 spurted out.  I personally HATE sudoku puzzles, and have
 only done three ever, but the challenge was interesting.
 Not like the world needs another sudoku-solver - there
 are TONS of them on the net.  And I learned some neat and
 strange things about sudoku puzzles.)


Re: test ignort
#247500
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 16:36
16 lines
351 bytes
"dt" <daletx@ATnewsguy.com> wrote in message
news:f63a7m$1fv$1@geraldo.cc.utexas.edu...
>
> Ned Ludd wrote:
>> Please ignore this - I'm just parking this here. - Ned
>
> Usenet as file storage?  Interesting concept.
> T
>

 Been doin' it for years.  (What do you think, I LIKE it here?)

                                                        Ned


Re: test ignort
#247612
Author: Pete
Date: Fri, 29 Jun 2007 18:03
23 lines
754 bytes
Ned writes:

> "Ben" <eggplantontoast@yahoo.co.uk> wrote in message
> news:46855933$0$4937$4c368faf@roadrunner.com...
>>>>>> Usenet as file storage?  Interesting concept.
>>>>>> T
>>>>> Been doin' it for years.  (What do you think, I LIKE it here?)
>>>>> Ned
>>>> Of course if you made the subject line something like "sudoko puzzle
>>>> from june 07" it might be easier to find later.
>>> Mmmm... I think searching for the text SUDOKUX.BAS would
>>> pretty much nail it.
>>> Ned
>> Probably.  But I would forget what text I thought I would remember when
>> I was looking for it again.
>> So I make sure one of my top three guesses will be correct.
>>
>
>   Oh, that's right... you're a Mac user.

Oh, a palpable touch! Score one for the Luddite.

Pete
Re: test ignort
#247523
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 18:54
23 lines
583 bytes
"Ben" <eggplantontoast@yahoo.co.uk> wrote in message
news:46854a92$0$4737$4c368faf@roadrunner.com...
>>>Ned Ludd wrote:
>>>>Please ignore this - I'm just parking this here. - Ned
>>>
>>>Usenet as file storage?  Interesting concept.
>>>T
>>
>> Been doin' it for years.  (What do you think, I LIKE it here?)
>> Ned
>
> Of course if you made the subject line something like "sudoko puzzle
> from june 07" it might be easier to find later.
>

  Mmmm... I think searching for the text SUDOKUX.BAS would
pretty much nail it.

                                                       Ned



Re: test ignort
#247532
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 19:12
23 lines
577 bytes
"Bj" <badaddress@realhhg.com> wrote in message
news:46855373$0$8720$ed2619ec@ptn-nntp-reader02.plus.net...
>
>> Please ignore this - I'm just parking this here. - Ned
>>
>> REM  Program SUDOKUX
>> REM  9/06 Ned Ludd
>> DIM endposs(50, 2)
>> CLEAR , , 2000
>> CLS
>> ulc$ = CHR$(201): urc$ = CHR$(187): llc$ = CHR$(200): lrc$ = CHR$(188)
>
> AAAAUUUGHHH!!! MY EYES!!!
> Couldn't you have marked that 'Not safe for structured programmers'?
> Bj
>

 BWAHAHAHAHA!  First, we kill all the structured programmers...

                                                           Ned


Re: test ignort
#247533
Author: "Ned Ludd"
Date: Fri, 29 Jun 2007 19:14
27 lines
742 bytes
"Ben" <eggplantontoast@yahoo.co.uk> wrote in message
news:46855933$0$4937$4c368faf@roadrunner.com...
>
>>>>> Usenet as file storage?  Interesting concept.
>>>>> T
>>>>
>>>> Been doin' it for years.  (What do you think, I LIKE it here?)
>>>> Ned
>>>
>>> Of course if you made the subject line something like "sudoko puzzle
>>> from june 07" it might be easier to find later.
>>
>> Mmmm... I think searching for the text SUDOKUX.BAS would
>> pretty much nail it.
>> Ned
>
> Probably.  But I would forget what text I thought I would remember when
> I was looking for it again.
> So I make sure one of my top three guesses will be correct.
>

  Oh, that's right... you're a Mac user.

                                                      Ned


Re: test ignort
#247521
Author: "Bj"
Date: Fri, 29 Jun 2007 19:46
23 lines
446 bytes
"Ned Ludd" <nedludd@ix.netcom.com> wrote in message
news:Mb9hi.2069$Od7.905@newsread1.news.pas.earthlink.net...
> Please ignore this - I'm just parking this here. - Ned
>
>
> REM  Program SUDOKUX
> REM  9/06 Ned Ludd
>
> DIM endposs(50, 2)
>
> CLEAR , , 2000
>
> CLS
>
> ulc$ = CHR$(201): urc$ = CHR$(187): llc$ = CHR$(200): lrc$ = CHR$(188)

AAAAUUUGHHH!!! MY EYES!!!

Couldn't you have marked that 'Not safe for structured programmers'?

Bj


Re: test ignort
#247661
Author: not.a.spam.drop@
Date: Sat, 30 Jun 2007 09:09
46 lines
1280 bytes
In article <46855b3a$0$3107$4c368faf@roadrunner.com>,
eggplantontoast@yahoo.co.uk says...
>
>Ned Ludd wrote:
>
>> "Ben" <eggplantontoast@yahoo.co.uk> wrote in message
>> news:46855933$0$4937$4c368faf@roadrunner.com...
>>
>>>>>>>Usenet as file storage?  Interesting concept.
>>>>>>>T
>>>>>>
>>>>>>Been doin' it for years.  (What do you think, I LIKE it here?)
>>>>>>Ned
>>>>>
>>>>>Of course if you made the subject line something like "sudoko puzzle
>>>>>from june 07" it might be easier to find later.
>>>>
>>>>Mmmm... I think searching for the text SUDOKUX.BAS would
>>>>pretty much nail it.
>>>>Ned
>>>
>>>Probably.  But I would forget what text I thought I would remember when
>>>I was looking for it again.
>>>So I make sure one of my top three guesses will be correct.
>>>
>>
>>
>>   Oh, that's right... you're a Mac user.
>>
>>                                                       Ned
>>
>>
>It's definitely made me lazy.  And less cautious about where I put things.
>
>I can't imagine growing up that way.
>
>Soon, I'll have tags in all my personal belongings, so when I get out of
>bed in the morning, and I can't find my glasses, I'll pull out my
>i-phone and type "glasses" into the serach box.

Heh, I'd forget to type "glasses"...


--
Giggles Like a Girl

Re: test ignort
#247757
Author: deelek Extermina
Date: Sun, 01 Jul 2007 10:04
26 lines
909 bytes
On 30 Jun, 00:35, "Ned Ludd" <nedl...@ix.netcom.com> wrote:
> "Pete" <eldup...@cox.net> wrote in message
>
> news:xz9hi.456304$g24.67293@newsfe12.phx...
>
>
>
> > If that's the holy grail of retirement, shoot me now.
> > Pete (insert winking emoticon here...)
>
>   Ha.  That's a keeper!
>
>                                                   Ned
>
> (It was a spasm six months ago.  I'd been retired for five
>  months and hadn't written any code, and it just kind of
>  spurted out.  I personally HATE sudoku puzzles, and have
>  only done three ever, but the challenge was interesting.
>  Not like the world needs another sudoku-solver - there
>  are TONS of them on the net.  And I learned some neat and
>  strange things about sudoku puzzles.)

I have tasted retirement life and can conclude that I shall make sure
I have tonnes of money before I really retire.  Otherwise it's just
demoralising.  Yeah.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads