Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Country Flags
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def find_move(A,T,i,j): if([i,j] not in T): if(i > 0 and i <len(A) and j > 0 and j<len(A[0])): return True def find_direction(A,T,i,j,C): TOP_MOVE = find_move(A,T,i-1,j) BOTTOM_MOVE = find_move(A,T,i+1,j) LEFT_MOVE = find_move(A,T,i,j-1) RIGHT_MOVE = find_move(A,T,i,j+1) if(TOP_MOVE and A[i][j] == A[i-1][j]): #C+=1 T.append([i-1,j]) find_direction(A,T,i-1,j,C) else: return C+1 if(BOTTOM_MOVE and A[i][j] == A[i+1][j]): #C+=1 T.append([i+1,j]) find_direction(A,T,i+1,j,C) else: return C+1 if(LEFT_MOVE and A[i][j] == A[i][j-1]): #C+=1 T.append([i,j-1]) find_direction(A,T,i,j-1,C) else: return C+1 if(RIGHT_MOVE and A[i][j] == A[i][j+1]): #C+=1 T.append([i,j+1]) find_direction(A,T,i,j+1,C) else: return C+1 def solution(A): COUNTRIES = 11 C=0 traversed_List = [] for i in range(len(A)): for j in range(len(A[0])): traversed_List.append([i,j]) C = find_direction(A,traversed_List,i,j,C) #print(C) return COUNTRIES
run
|
edit
|
history
|
help
0
Hello wold Happy
kenken1
Celcius to Fahrenheit
shuru16
Faiha - Selection Sort
ALAMOST DONUTZ dungeon
Butch
FizzBuzz
max/min fuction
Traceback prettyfy.py