[Horse racing task] Add initialize method and change variable names#4
Open
Slavunderkind wants to merge 3 commits intomasterfrom
Open
[Horse racing task] Add initialize method and change variable names#4Slavunderkind wants to merge 3 commits intomasterfrom
Slavunderkind wants to merge 3 commits intomasterfrom
Conversation
vasil-gochev
requested changes
Jan 12, 2017
horse_racing.rb
Outdated
| end | ||
|
|
||
| def find_difference | ||
| strenghts = init_strenghts |
horse_racing.rb
Outdated
| attr_accessor :horses_number | ||
|
|
||
| def initialize | ||
| @horses_number = gets.to_i |
Collaborator
There was a problem hiding this comment.
It's better to use count or size instead of number for variables that express count or size
horse_racing.rb
Outdated
| n.times do | ||
| pi = gets.to_i | ||
| strenghts_array << pi | ||
| horses_number.times do |
Collaborator
There was a problem hiding this comment.
Try using each_with_object. You can also chain it to .times
b8e5d88 to
73f6435
Compare
383bb52 to
224785d
Compare
Training/Easy/horse_racing.rb
Outdated
| horses_count.times.each_with_object([]) { |_, result| result << gets.to_i }.sort | ||
| end | ||
|
|
||
| def start |
Collaborator
There was a problem hiding this comment.
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
Training/Easy/horse_racing.rb
Outdated
| @horses_count = gets.to_i | ||
| end | ||
|
|
||
| def find_difference |
Collaborator
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.