Ask a graph theory related algorithm.

to make an educational Mini Game
, there is a 5"6 matrix, as shown in the following figure
01 02 03 04 05 06
07 08 09 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30

want to randomly select a point from the matrix, take this point as the starting point, walk 8 distances, the direction can be upper, lower, left, right, upper left, upper right, lower left, lower right, lower right. One point at a time, you can"t go to this point next time. How to write an algorithm that can randomly take 8 steps?

such as 1-> 2-> 3-> 4-> 5-> 6-> 11-> 12.
such as 7-> 8-> 2-> 1 so there is no place to go after 4 steps.
how to connect 8 random points and get through.

Aug.01,2021

depth-first traversal to find out

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf8702-3193f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf8702-3193f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?