8 Queens
-
Imagine there are 8 queens attending a race. On your computer screen
each queen is represented by a character 'Q'. On each row there is one
queen.
-
If you think a single character is monotonous, you may modify this
program to handle 8 horses ~/-\^
-
Use a random number generator to determine which queen will move
forward.
-
You may use the sleep() function to slow down the program.
-
Suppose the length of each lane is 50. The first queen who arrives at
the destination wins the race.
- While you are developing and testing your code, you may shorten
the length to become 10 so that it takes less time to finish a test.
The program may run as follows: