-
Notifications
You must be signed in to change notification settings - Fork 0
bowling code #3
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
base: main
Are you sure you want to change the base?
bowling code #3
Conversation
| @@ -0,0 +1,46 @@ | |||
| require 'date' | |||
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.
カレンダーのプログラムがPRに混じってしまっていますね。新しいブランチを作成する際は、今どのブランチにいるのかに注意して作成するようにしましょう。今回はこのままでOKです。
| end | ||
|
|
||
| frames = [] | ||
| shots.each_slice(2) do |s| |
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.
ここは以下のように書けますね。
frames = shots.each_slice(2).to_a| # binding.break | ||
| if index >=9 | ||
| point += frame.sum | ||
| # elsif frame_index == 11 |
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.
不要であれば削除しておきましょう。3行↑にある binding.break も同様です。
| shots.each_slice(2) do |s| | ||
| frames << s | ||
| end | ||
| p frames |
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.
デバッグ用だと思うので、削除しておきましょう。
| p frames | ||
| point = 0 | ||
|
|
||
| frames.each_with_index do |frame, index| |
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.
ここは以下のように Enumerable#sum を使うと、自分で point を加算しなくて良くなるはずです。
point = frames.each_with_index.sum do |frame, index|
# 戻り値を各フレームのスコアにする
end
No description provided.