Write a function that takes a two-dimensional list of numbers as a parameter. It
ID: 641015 • Letter: W
Question
Write a function that takes a two-dimensional list of numbers as a parameter. It returns the index of the minimum row in the list. The minimum row is the row with the smallest sum of elements.
This is what I currently have:
def min_row(lst):
minimum = lst[0]
for i in range(len(lst)):
if lst[i] < minimum:
minimum = lst[i]
return minimum
This returns the minimum row, not the index of the row
Explanation / Answer
>> x = randi(5, 5) x = 5 4 4 2 4 4 2 4 5 5 3 1 3 4 3 3 4 2 5 1 2 4 5 3 5 >> [value, index] = min(reshape(x, numel(x), 1)); >> [i,j] = ind2sub(size(x), index) i = 3 j = 2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.