Draw a line that starts at 0 and visits numbers 0 to 9 in order. The line can only be horizontal or vertical, cannot cross itself, and can only change direction at dots. All dots must be visited.
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . 2 .
. . . 9 . . 0 . . .
. . . . . . . . . .
. . . . 5 . 7 . . .
. . 6 . . 8 . . . .
. 1 . . . . . . . .
. 3 . . . . . . . 4
. . . . . . . . . .
(In reply to
re: ...but can I draw it? by Charlie)
That's the best transcription I can make from Jer's directions.
However, most numbered positions have a direction change. Does a number count as a dot, where a direction change is allowed? (Only 4, other than the obvious 0 and 9, does not have a direction change).
DATA DRRDDDDLLLLLULL(1)
DATA UUUUUURRRRRRRD(2)
DATA RUULLLLLLLLLDDDDDDDDDRU(3)
DATA RDRRRRRRRU(4)
DATA UUUUULLULLLLLDDRRD(5)
DATA LLD(6)
DATA RRDRRRUUL(7)
DATA DL(8)
DATA UUULL(9)
FOR i = 1 TO 9: READ dir$(i): NEXT
row = 4: col = 7: board$(row, col) = "0"
FOR piece = 1 TO 9
FOR p = 1 TO LEN(dir$(piece)) - 3
d$ = MID$(dir$(piece), p, 1)
SELECT CASE d$
CASE "D"
row = row + 1
SELECT CASE MID$(dir$(piece), p + 1, 1)
CASE "D"
cd$ = "02"
CASE "R"
cd$ = "14"
CASE "L"
cd$ = "18"
CASE "("
cd$ = "--"
END SELECT
CASE "U"
row = row - 1
SELECT CASE MID$(dir$(piece), p + 1, 1)
CASE "U"
cd$ = "02"
CASE "R"
cd$ = "0C"
CASE "L"
cd$ = "10"
CASE "("
cd$ = "--"
END SELECT
CASE "R"
col = col + 1
SELECT CASE MID$(dir$(piece), p + 1, 1)
CASE "D"
cd$ = "10"
CASE "R"
cd$ = "00"
CASE "U"
cd$ = "18"
CASE "("
cd$ = "--"
END SELECT
CASE "L"
col = col - 1
SELECT CASE MID$(dir$(piece), p + 1, 1)
CASE "D"
cd$ = "0C"
CASE "U"
cd$ = "14"
CASE "L"
cd$ = "00"
CASE "("
cd$ = "--"
END SELECT
END SELECT
IF cd$ = "--" THEN
board$(row, col) = MID$(dir$(piece), p + 2, 1)
ELSE
board$(row, col) = "%" + cd$ + ";"
END IF
NEXT
NEXT
OPEN "ccc.HTM" FOR OUTPUT AS #2
FOR row = 1 TO 10
FOR col = 1 TO 10
PRINT #2, board$(row, col); " ";
NEXT
PRINT #2, "<br>"
NEXT
CLOSE
|
Posted by Charlie
on 2005-03-10 20:07:26 |