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 »
please use the template provided. i will be graded according to that. we are strictly suggested to use that template.


QUIZ 6 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 quiz_6.py Enter two integers: 0 1 Here is the grid that has been generated: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 No chess knight has explored this board. $ python3 quiz_6.py Enter two integers: 0 -20 Here is the grid that has been generated: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 0 0 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 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: 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 0 1 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: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 No chess knight has explored this board. $ python3 quiz_6.py Enter two integers: 0 -20 Here is the grid that has been generated: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 0 0 0 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: 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 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: 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 0 1 At least 3 chess knights have explored this board.
Answered Same DaySep 05, 2020COMP9021

Answer To: QUIZ 6 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 quiz_6.py Enter two integers: 0 1 Here is the...

Snehil answered on Sep 09 2020
148 Votes
# Randomly fills an array of size 10x10 True and False, displayed as 1 and 0,
# and outputs the number chess knights ne
eded 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 current 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