Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rspec'
require 'rspec/its'
require_relative 'task_seven'
RSpec.describe TaskSeven do
let(:array) { [5, -3, 3, -5, 6, 6, 6, -1, 0, 2] }
subject { described_class.new array }
its(:number_elements_after_max) { should eq 3 }
end
class TaskSeven
def initialize array
@array = array
end
def number_elements_after_max
max_index = 0
max_value = @array[0]
@array.each_with_index do |value, index|
if max_value <= value
max_value = value
max_index = index
end
end
@array.count - max_index - 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.