Read sections 3.1-3.8 in chapter 3 of the textbook Explorations in Computing.
def findmin(list) position = 0 min = list[0] for i in 1..list.length-1 do if list[i] < min then position = i min = list[i] end end return position end
===================================== list position min i ===================================== [4,6,3,5] 0 4 - =====================================
n = 9 for i in 1..n do for j in 1..n do print i*j, "\t" end puts end
(1..10).each {|i| (1..i).each {|j| print "*"}; puts}
data = [ [0,0,0,0,5], [0,0,0,2,9], [0,0,4,1,3], [0,0,0,8,6], [0,0,0,0,7] ] >> show_nonzero(data) [5] [2, 9] [4, 1, 3] [8, 6] [7] =>nilYou can write the show_nonzero(x) function by using a for loop to iterate over the elements of x, and using drop_while to drop the leading zeros from each entry. Write down the definition for this function. Note: to print out an array in proper array notation (using square brackets and commas, as shown above) you must use "p" instead of "puts".