Skip to content

Conversation

@Slavunderkind
Copy link
Owner

No description provided.

@Slavunderkind Slavunderkind requested review from a user and vasil-gochev January 12, 2017 09:24
@Slavunderkind Slavunderkind changed the title Add initialize method and change variable names [Horse racing task] Add initialize method and change variable names Jan 12, 2017
horse_racing.rb Outdated
end

def find_difference
strenghts = init_strenghts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strengTH :)

horse_racing.rb Outdated
attr_accessor :horses_number

def initialize
@horses_number = gets.to_i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use count or size instead of number for variables that express count or size

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure 👍

horse_racing.rb Outdated
n.times do
pi = gets.to_i
strenghts_array << pi
horses_number.times do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using each_with_object. You can also chain it to .times

@Slavunderkind Slavunderkind force-pushed the master branch 4 times, most recently from b8e5d88 to 73f6435 Compare January 17, 2017 14:56
horses_count.times.each_with_object([]) { |_, result| result << gets.to_i }.sort
end

def start
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the start method altogether, just use your find_difference function:

obj = HorceRacing.new
answer = obj.start
puts answer

or even

answer = HorceRacing.new.start
puts answer

@horses_count = gets.to_i
end

def find_difference
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method does two things - it inializes strengths and it also finds their difference. Try to refactor it so that it only does one thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants