関数mergeで多かった回答は穴埋めで,
def merge(a,b)
c = make1d(a.length()+b.length())
ia =0
ib =0
ic =0
while ia < a.length() && ib < b.length()
if a[ia] < b[ib]
c[ic] = a[ia]
ia = ia + 1
ic = ic + 1
else
c[ic] = b[ib]
ib = ib + 1
ic = ic + 1
end
end
while ia< a.length()
c[ic]=a[ia]
ia=ia+1
ic=ic+1
end
while ib< b.length()
c[ic]=b[ib]
ib=ib+1
ic=ic+1
end
c
end
とするもの.一方,
def merge(a,b)
c = make1d(a.length()+b.length())
ia =0
ib =0
ic =0
while ia < a.length() && ib < b.length()
if a[ia] < b[ib]
c[ic] = a[ia]
ia = ia + 1
ic = ic + 1
else
c[ic] = b[ib]
ib = ib + 1
ic = ic + 1
end
end
if ia < a.length()
for i in ia..(a.length()-1)
c[ic] = a[i]
ic = ic + 1
end
else
if ib < b.length()
for i in ib..(b.length()-1)
c[ic] = b[i]
ic = ic + 1
end
end
end
end
のように答えた人もいて,当然こちらも正解です.