# Untitled

unknown
python
10 months ago
3.2 kB
6
Indexable
Never
```import random;

matriz =[[" "," "," "," "," "],[" "," "," "," "," "],[" "," "," "," "," "],[" "," "," "," "," "],[" "," "," "," "," "]]

def print_matriz():
print("------------------");
aux = str("");
i = 0;
while(i < len(matriz)):
j = 0;
while(j < len(matriz)):
aux = aux + str(matriz[i][j]) + "\t";
j = j + 1;
i = i + 1;
print(aux);
aux = "";
print("------------------");

def numbers():
print("you have to choose the minimun and maximum for filling up a square");
aux2 = False;
while(aux2 == False):
aux = False;
aux1 = False;
while(aux == False):
min = input("which number do you want to be the minimum? ");
try:
int(min);
min = int(min);
aux = True;
except:
while(aux1 == False):
max = input("which number do you want to be the maximum? ");
try:
int(max);
max = int(max);
aux1 = True;
except:
if(max - min < 0):
print("maximum must be bigger than minimum");
aux2 = False;
else:
aux2 = True;
place_numbers(min,max);
biggest_recursive(auxialiary,0,1,0);
print("the column/s with biggest addition is/are: ")
print_result(0);

def place_numbers(min,max):
i = 0;
while(i < len(matriz)):
j = 0;
while(j < len(matriz)):
matriz[i][j] = random.randint(min,max);
j = j + 1;
print_matriz();
i = i + 1;

auxialiary = [0,0,0,0,0];
count = 0;
biggest_recursive(auxialiary,0,1,0);
if(i < 4):
print("until now the biggest column/s is/are:");
print_result(0);

global auxialiary;
global count;
if(j == len(matriz)):
count = count + 1;
return;
try:
if(j == 0):
auxialiary[0] = auxialiary[0] + matriz[i][j];
elif(j == 1):
auxialiary[1] = auxialiary[1] + matriz[i][j];
elif(j == 2):
auxialiary[2] = auxialiary[2] + matriz[i][j];
elif(j == 3):
auxialiary[3] = auxialiary[3] + matriz[i][j];
elif(j == 4):
auxialiary[4] = auxialiary[4] + matriz[i][j];
addition_recursive(i, j + 1);
except:
return;

auxialiary1 = ["","","","",""];

def biggest_recursive(array, position, comparable, counter):
global auxialiary1;
if(position + comparable == len(array)):
return;
if(array[position] < array[position + comparable]):
auxialiary1 = ["","","","",""];
auxialiary1[0] = str(position + comparable);
biggest_recursive(array, position + comparable, 1, 1);
elif(array[position] > array[position + comparable]):
if(counter == 0):
auxialiary1 = ["","","","",""];
auxialiary1[0] = str(position);
biggest_recursive(array, position, comparable + 1, 1);
else:
if(counter == 0):
auxialiary1[0] = str(position);
counter = counter + 1
auxialiary1[counter] = str(position + comparable);
biggest_recursive(array, position, comparable + 1, counter + 1);

def print_result(position):
if(position == len(auxialiary1)):
return;
try:
int(auxialiary1[position]);
print(int(auxialiary1[position]) + 1);
print_result(position + 1);
except:
return;

numbers();
```