tests
This commit is contained in:
parent
f92f5ef7f6
commit
307c51539c
10 changed files with 252 additions and 1 deletions
27
test/ruby/26.in
Normal file
27
test/ruby/26.in
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
def find_max_min(numbers):
|
||||
if not numbers:
|
||||
return None, None
|
||||
|
||||
max_num = numbers[0]
|
||||
min_num = numbers[0]
|
||||
|
||||
for num in numbers[1:]:
|
||||
if num > max_num:
|
||||
max_num = num
|
||||
if num < min_num:
|
||||
min_num = num
|
||||
|
||||
return max_num, min_num
|
||||
|
||||
def reverse_list(items):
|
||||
reversed_items = []
|
||||
for i in range(len(items) - 1, -1, -1):
|
||||
reversed_items.append(items[i])
|
||||
return reversed_items
|
||||
|
||||
numbers = [3, 1, 4, 1, 5, 9, 2, 6]
|
||||
max_val, min_val = find_max_min(numbers)
|
||||
print(f"List: {numbers}")
|
||||
print(f"Max: {max_val}, Min: {min_val}")
|
||||
print(f"Reversed: {reverse_list(numbers)}")
|
||||
print(f"Original list unchanged: {numbers}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue