Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

QUIZ 6 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 quiz_6.py Enter two integers: 0 1 Here is the grid that has been generated: XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX...

1 answer below »
QUIZ 6
COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_6.py
Enter two integers: 0 1
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
No chess knight has explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -20
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 2 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -6
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 7 chess knights have explored this board.
Date: Session 2, 2018.
2 COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_6.py
Enter two integers: 0 -5
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 8 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -4
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 6 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 3
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 3 chess knights have explored this board.

QUIZ 6
COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_6.py
Enter two integers: 0 1
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
No chess knight has explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -20
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 2 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -6
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 7 chess knights have explored this board.
Date: Session 2, 2018.
2 COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_6.py
Enter two integers: 0 -5
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 8 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 -4
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 6 chess knights have explored this board.
$ python3 quiz_6.py
Enter two integers: 0 3
Here is the grid that has been generated:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
At least 3 chess knights have explored this board.
Answered Same Day Sep 05, 2020 COMP9021

Solution

Snehil answered on Sep 09 2020
146 Votes
# Randomly fills an a
ay of size 10x10 True and False, displayed as 1 and 0,
# and outputs the number chess knights needed to jump from 1s to 1s
# and visit all 1s (they can jump back to locations previously visited).
#
# Written by *** and Eric Martin for COMP9021
from random import seed, randrange
import sys
dim = 10
def display_grid():
for i in range(dim):
print(' ', end = '')
print(' '.join(grid[i][j] and '1' or '0' for j in range(dim)))
print()
#a list of all valid moves for a knight if given row/column values are added to knights cu
ent position
available_moves = [[2,1],[1,2],[-1,2],[-2,1],[-2,-1],[-1,-2],[1,-2],[2,-1]]
#a matrix to store all unvisited locations
locations = [[True for _ in range(dim)] for _ in range(dim)] #marked all as visited
#function to return first unvisited location found, None if not found
def get_unexplored_location(locations):
for i in range(dim):
for j in range(dim):
if locations[i][j] == False:#location has not been visited
return [i,j]#return unvisited location
return None ##loop complete and no unvisited location found

def explore_board():

...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here