Fix interface of bucket_sort for testing

This commit is contained in:
vzvu3k6k 2021-02-14 03:43:32 +09:00
parent bc96d1c4ea
commit aeb2478faa

View file

@ -1,10 +1,6 @@
DEFAULT_BUCKET_SIZE = 5
def bucket_sort(input, bucket_size = DEFAULT_BUCKET_SIZE)
print 'Array is empty' if input.empty?
array = input.split(' ').map(&:to_i)
def bucket_sort(array, bucket_size = DEFAULT_BUCKET_SIZE)
bucket_count = ((array.max - array.min) / bucket_size).floor + 1
# create buckets
@ -21,7 +17,7 @@ def bucket_sort(input, bucket_size = DEFAULT_BUCKET_SIZE)
bucket.sort!
end
buckets.flatten.join(' ')
buckets.flatten
end
puts 'Enter a list of numbers separated by space'