Import random
def copy_1d(lst):
b = []
for item in lst:
b. append(item)
ret...
![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 23.03.2021 22:10 emmapaschen
Import random
def copy_1d(lst):
b = []
for item in lst:
b. append(item)
return b
def copy_two_d(a):
b = []
for sublist in a:
b. append(copy_1d(sublist))
return b
def three_d_false(n):
pre_1 = [False]
pre_1 *= n
pre_2 = []
for i in range(n):
pre_2.append(copy_1d(pre_1))
final = []
for i in range(n):
final. append(copy_two_d(pre_2))
return final
def three_d_selfavoid(n, trials):
deadEnds = 0
length = 0
for i in range(trials):
been_there = three_d_false(n)
x = n // 2
y = n // 2
z = n // 2
while x > 0 and x < n - 1 and y > 0 and y < n - 1 and z > 0 and z < n - 1:
been_there[x][y][z] = True
print(x, y, z)
if been_there[x + 1][y][z] and been_there[x - 1][y][z] and been_there[x][y - 1][z] and been_there[x][y + 1][z] and been_there[x][y][z + 1] and been_there[x][y][z - 1]:
deadEnds += 1
break
r = random. randrange(1, 7)
if r == 1 and not been_there[x + 1][y][z]:
x = x + 1
length += 1
print(1)
elif r == 2 and not been_there[x - 1][y][z]:
x = x - 1
length += 1
print(2)
elif r == 3 and not been_there[x][y + 1][z]:
y = y + 1
length += 1
print(3)
elif r == 4 and not been_there[x][y - 1][z]:
y = y - 1
length += 1
print(4)
elif r == 5 and not been_there[x][y][z + 1]:
z = z + 1
length += 1
print(5)
elif r == 6 and not been_there[x][y][z - 1]:
z = z - 1
length += 1
print(6)
print(length / trials, deadEnds / trials * 100)
three_d_selfavoid(3, 100)
However, when I run this, it just keeps x, y, and z at 1, 1, and 1. What's wrong...
![ansver](/tpl/images/cats/User.png)
Answers: 1
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have used—for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 07:00
You are most likely to automatically encode information about
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 13:30
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. the program should output the average high, average low, and the highest and lowest temper- atures for the year. your program must consist of the following functions: a. function getdata: this function reads and stores data in the two- dimensional array. b. function averagehigh: this function calculates and returns the average high temperature for the year. c. function averagelow: this function calculates and returns the aver- age low temperature for the year. d. function indexhightemp: this function returns the index of the highest high temperature in the array. e. function indexlowtemp: this function retur
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 21:40
Assume you need to test a function named inorder. the function inorder receives three int arguments and returns true if and only if the arguments are in non-decreasing order: that is, the second argument is not < the first and the third is not < the second. write the definition of driver function testinorder whose job it is to determine whether inorder is correct. so testinorder returns true if inorder is correct and returns false otherwise. for the purposes of this exercise, assume inorder is an expensive function call, so call it as few times as possible!
Answers: 1
You know the right answer?
Questions
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.03.2020 12:35
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/pravo.png)
![question](/tpl/images/cats/en.png)
English, 24.03.2020 12:37
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.03.2020 12:38
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
English, 24.03.2020 12:39
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
English, 24.03.2020 12:41
![question](/tpl/images/cats/mat.png)
Mathematics, 24.03.2020 12:41
![question](/tpl/images/cats/fizika.png)
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 24.03.2020 12:42
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/himiya.png)
Chemistry, 24.03.2020 12:43
![question](/tpl/images/cats/en.png)
English, 24.03.2020 12:44
![question](/tpl/images/cats/himiya.png)
Chemistry, 24.03.2020 12:44