Proaxis
Ruby
code posted
created at 15 Oct 12:09
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 |
def find_smallest array1, array2 min = Float::INFINITY array1.each_with_index { |elem1,i| array2.each_with_index{ |elem2, j| diff = (elem1 - elem2).abs min = diff unless diff > min } } min end puts find_smallest array1, array2 # 57 |
257 Bytes in 2 ms with coderay