mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-17 06:11:43 +01:00
Fix interface of bucket_sort for testing
This commit is contained in:
parent
bc96d1c4ea
commit
aeb2478faa
1 changed files with 2 additions and 6 deletions
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in a new issue