Inputs:
a=[1,2,3,4,5,6,7,8,9,10]
b=[1,2,4,5,6,7,8,9,10]
missing_elements = []
for i in a.min..a.max
missing_elements.push(i) unless b.include?(i)
end
missing_elements.each do |m|
b.insert(a.index(m),0)
end
p a
p b
for i in 0..a.length-1
puts "#{a[i]}-#{b[i]}"
end
OUTPUT:
1-1
2-2
3-0
4-4
5-5
6-6
7-7
8-8
9-9
10-10
a=[1,2,3,4,5,6,7,8,9,10]
b=[1,2,4,5,6,7,8,9,10]
missing_elements = []
for i in a.min..a.max
missing_elements.push(i) unless b.include?(i)
end
missing_elements.each do |m|
b.insert(a.index(m),0)
end
p a
p b
for i in 0..a.length-1
puts "#{a[i]}-#{b[i]}"
end
OUTPUT:
1-1
2-2
3-0
4-4
5-5
6-6
7-7
8-8
9-9
10-10