diff --git a/lab3_task1_funcation_block_arg/main.rb b/lab3_task1_funcation_block_arg/main.rb index f2bbf90..6f150bb 100644 --- a/lab3_task1_funcation_block_arg/main.rb +++ b/lab3_task1_funcation_block_arg/main.rb @@ -37,6 +37,12 @@ def elements_between_first_and_last_max(array) end +def minimal_even_element(array) + even_elements = array.select(&:even?) + even_elements.min +end + + # Ex array = [5, 3, 8, 1, 7] puts "Indices in order of decreasing elements:" @@ -48,4 +54,8 @@ puts elements_between_first_and_second_max(array).join(", ") array = [5, 1, 8, 3, 7, 8] puts "Elements between first and last maximum:" -puts elements_between_first_and_last_max(array).join(", ") \ No newline at end of file +puts elements_between_first_and_last_max(array).join(", ") + +array = [5, 2, 8, 3, 7] +puts "Minimal even element:" +puts minimal_even_element(array)