Minor code style improvements

Tabs are corrected, semantic blocks are separated.
This commit is contained in:
nyapsilon 2021-04-09 21:24:04 +03:00 committed by GitHub
parent 4fa7e1a672
commit e6b674275e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,18 +8,21 @@ def binary_search(array, key)
return middle if array[middle] == key
if key < array[middle]
back = middle - 1
else
front = middle + 1
end
back = middle - 1
else
front = middle + 1
end
end
nil
end
puts "Enter a sorted space-separated list:"
arr = gets.chomp.split(' ').map(&:to_i)
puts "Enter the value to be searched:"
value = gets.chomp.to_i
puts if binary_search(arr, value) != nil
"Found at index #{binary_search(arr, value)}"
else