-
Notifications
You must be signed in to change notification settings - Fork 167
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
implement hw 1 #767
base: master
Are you sure you want to change the base?
implement hw 1 #767
Changes from 2 commits
6f049c7
2e7001d
b18b1aa
9ba3bd9
82c0465
2ed5adc
cc84521
1409731
10e6100
e8f2340
d275ee0
3d1ecd1
30d5bcf
9f4f1d7
d5a9453
36b4e00
164758f
d571c18
ee97bb1
fa274fa
63b1e72
34166a4
3e3f87a
d7939e3
825907a
873d583
fd118f5
186e159
3c2e868
2f70e50
d9dea00
e03731e
ff12845
2928792
18a8b3e
7627b23
2a33924
3045604
34f2356
d23871f
281bcd3
2541d2f
2ef4e51
4359fb7
2cba762
f59d090
97b9ff1
baef018
b6c5ceb
7507247
24896d7
ff7486a
bd602a4
6f14fdd
63080f1
3cfc6c3
98feca9
a65f132
0a81162
fe78f96
1dae54e
c40c44b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
def triangle(n, z, c) | ||
(0..n).map do |r| | ||
n = [0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not -1) spaces for indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not -2) spaces for indentation. |
||
num = [c] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
left = [z] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
right = z | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
c = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
k = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
(0..r - 1).step(1) do | ||
|index| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Block argument expression is not on the same line as the block start. |
||
right = right * (r - k + 1) / k | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not 0) spaces for indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not -2) spaces for indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not -4) spaces for indentation. |
||
left.push right | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
c += 1 | ||
k += 1 | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. end at 14, 0 is not aligned with (0..r - 1).step(1) do at 9, 2. |
||
num.to_s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
left.to_s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation detected. |
||
puts "#{n.center(130).green} #{m.rjust(13)}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. end at 18, 0 is not aligned with (0..n).map do |r| at 2, 2. |
||
end | ||
print 'enter the vertex of the triangle:' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
z = gets.to_i | ||
print 'enter the depth of the triangle:' | ||
n = gets.to_i | ||
puts "vertex triangle = #{z}" | ||
puts "depth triangle = #{n}" | ||
require 'colorize' | ||
triangle(n, z, c = 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless assignment to variable - c. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless assignment to variable - c. |
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.
Use 2 (not 0) spaces for indentation.