Sha256: dbcc386bfb9d2f6eb86e6e130179cc71a51c92f04c169ee1b6d874f8a4831454
Contents?: true
Size: 410 Bytes
Versions: 2
Compression:
Stored size: 410 Bytes
Contents
def bubble(numbers) for i in (0..numbers.size-1) for j in (i..numbers.size-1) if numbers[i] > numbers[j] temp = numbers[i] numbers[i] = numbers[j] numbers[j] = temp end end end numbers end # Reading the input input = gets input = input.split(' ')[1..-1].map {|c| c.to_i } bubble(input) # Printing the output puts input.inject {|output, n| "#{output} #{n}"}
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jeka-0.1.1 | test/example/01_bubble_sort/ruby/bubble.rb |
jeka-0.1.0 | test/example/01_bubble_sort/ruby/bubble.rb |