-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sat public review Command A (Zal 3) #16
base: sat-public-review
Are you sure you want to change the base?
Sat public review Command A (Zal 3) #16
Conversation
sets = towers.map do |tower| | ||
result = [] | ||
column = Array.new(@tower_size, " ") | ||
column.each_index do |i| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each_with_object
method might be used in cases you want to fill new Array/Hash by iterating some data,
result[i] = tower[i] | ||
else | ||
result[i] = column[i] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice practice to use oneliners like result[i] = tower[i] ? tower[i] : column[i]
@@ -0,0 +1,6 @@ | |||
require_relative './towers_of_hanoi' | |||
|
|||
if __FILE__ == $PROGRAM_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I remember we agreed that this checkup would be excessive
end | ||
@towers = @towers.map{|column| column.reject{|x| x == " "} } | ||
@sets | ||
self.towers = towers.map{|column| column.reject{|x| x == " "} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of a real project with larger classes and significant amount of variables and methods self.towers = towers might look confusing. In future try to find more clear way of assignment )
No description provided.