All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Unfilled grid (Posted on 2006-05-23)
Fill as much of a 6x6 grid with the letters A, B, C, D, E, F so no two of the same letter are in the same row, column or diagonal.

It is impossible to entirely fill the grid, but what is the largest number of letters that may be placed?

 See The Solution Submitted by Jer Rating: 4.1429 (7 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Possible solution. | Comment 4 of 5 |
(In reply to Possible solution. by Dej Mar)

Indeed, the last few found by the corrected program are:

4
bAcdef
dbaefc
eFdcba
4
bAcdef
dbaefc
eFdcba
4
acebfD
bfacde
cedFba
dbcAef
eafdcb
fdbeaC
4
acebfD
bfacde
cedAbf
dbcFea
eafdcb
fdbeaC
4
acebfD
bdfcae
dbcfea
eFdacb
fabedC
4
acebfD
bAfcde
cedabf
dbcfea
fdbeaC

The corrected portions of the program involve switching rows and columns:

DECLARE SUB place (row!, col!)
CLEAR , , 9999
l\$ = "abcdef": leastCt = 999
FOR i = 1 TO 6
g\$(i, 1) = MID\$(l\$, i, 1)
NEXT

place 1, 2

SUB place (row, col)
FOR i = 6 TO 1 STEP -1
lt\$ = MID\$(l\$, i, 1)
good = 1
FOR c = 1 TO col - 1
IF g\$(row, c) = lt\$ THEN good = 0: EXIT FOR
NEXT
IF good THEN
FOR r = 1 TO row - 1
IF g\$(r, col) = lt\$ THEN good = 0: EXIT FOR
NEXT
END IF
IF good THEN
g\$(row, col) = lt\$
conflict = 0
FOR c = 1 TO col - 1
r = row - (col - c)
IF r > 0 THEN IF g\$(r, c) = lt\$ THEN conflict = 1: EXIT FOR
r = row + (col - c)
IF r < 7 THEN IF g\$(r, c) = lt\$ THEN conflict = 1: EXIT FOR
NEXT

IF row = 6 AND col = 6 THEN
PRINT leastCt
FOR r = 1 TO 6
FOR c = 1 TO 6
PRINT UCASE\$(g\$(r, c));
ELSE
PRINT g\$(r, c);
END IF
NEXT
PRINT
NEXT
PRINT
END IF
ELSE
r = row + 1: c = col
IF r > 6 THEN r = 1: c = c + 1
place r, c
END IF

END IF
NEXT i
END SUB

 Posted by Charlie on 2006-05-23 23:57:51

 Search: Search body:
Forums (0)