Im writing a program in python that creates a function which paths a white line right or down in an array depending on the greater value of the adjacent random number. I have been emailing my professor and I think I have written it properly. The code is not running through enough iterations to draw the line of 1's through the Array.
import numpy as np
from matplotlib.pyplot import *
def im(A):
i=0;
j=0;
S=A.shape
while i<S[0] and j<S[1]:
if (A[i+1,j]>A[i,j+1]):
A[i+1,j]=1;
i=i+1;
else:
A[i,j+1]=1;
j=j+1;
return A
A=np.random.rand(10,10)*0.5
A=im(A)
figure(1), imshow(A,cmap='gray')
Aucun commentaire:
Enregistrer un commentaire