Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Code required: For test case, refer to: https://drive.google.com/file/d/13aiAZ5LKTqsf4l2T-j_OMjR4wPddOlK2/view?usp=sharing # Randomly fills an array of size 10x10 with True and False, # displayed as 1

Python Code required:

For test case, refer to: https://drive.google.com/file/d/13aiAZ5LKTqsf4l2T-j_OMjR4wPddOlK2/view?usp=sharing

# Randomly fills an array of size 10x10 with True and False,

# displayed as 1 and 0, and outputs the number of chess knights

# needed to jump from 1s to 1s and visit all 1s (they can jump back

# to locations previously visited).

from random import seed, randrange

import sys

dim = 10

def display_grid():

for row in grid:

print('', ' '.join(str(int(e)) for e in row))

try:

for_seed, n = (int(i) for i in input('Enter two integers: ').split())

if not n:

n = 1

except ValueError:

print('Incorrect input, giving up.')

sys.exit()

seed(for_seed)

if n > 0:

grid = [[randrange(n) > 0 for _ in range(dim)] for _ in range(dim)]

else:

grid = [[randrange(-n) == 0 for _ in range(dim)] for _ in range(dim)]

print('Here is the grid that has been generated:')

display_grid()

# INSERT YOUR CODE HERE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Explain the four steps in the control process.

Answered: 1 week ago