Skip to content
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

Open
wants to merge 4 commits into
base: sat-public-review
Choose a base branch
from

Conversation

samsonovkirill
Copy link
Contributor

@samsonovkirill samsonovkirill commented Apr 3, 2021

No description provided.

sets = towers.map do |tower|
result = []
column = Array.new(@tower_size, " ")
column.each_index do |i|

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

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

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 == " "} }

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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants