#I get the desired output but the interpreter throws an ArgumentError-bad value for range ?
Q)Given an array of integers, for each integer output all integers from 1 to that integer; e.g. if the integer was 5, you would output 1, 2, 3, 4, 5.
Solution:
numbers = [7, 3, 5, 2, 1, 8, 4]
counter = 0 loop do num = numbers[counter] (1..num).each do |ele| puts ele
end
counter += 1
end
Aucun commentaire:
Enregistrer un commentaire