Skip to content

Create 0006-zigzag-conversion.md - #61

Open
naoto-iwase wants to merge 1 commit into
mainfrom
0006-zigzag-conversion
Open

Create 0006-zigzag-conversion.md#61
naoto-iwase wants to merge 1 commit into
mainfrom
0006-zigzag-conversion

Conversation

@naoto-iwase

Copy link
Copy Markdown
Owner

break
yield s[s_index]

return "".join(generate_zigzag())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

行ごとに文字を返していく方法だと理解しました。一つのサイクルには 0 と numRows - 1 以外の行の文字は二つずつあるんですね。この点には注目できなくて参考になります。

関数名ですが、zigzag を generate しているわけではないような気がしており、generate_rows などの方が近い気がしておりますがいかがでしょうか。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数名ですが、zigzag を generate しているわけではないような気がしており、generate_rows などの方が近い気がしておりますがいかがでしょうか。

確かにその通りですね... おっしゃるとおり、generate_rowsやgenerate_row_by_rowなどが適切に思えました。

@shintaro1993

Copy link
Copy Markdown

Arai60 お疲れ様でした。
短期間で走り抜けられておりとても刺激になりました。

Grind75 に行かれるようでしたら、引き続きよろしくお願いいたします。

if numRows == 1 or len(s) <= numRows:
return s

row = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

row_index など、行番号のニュアンスがあっても良いかなと思いました。row の場合、内容を読む前だと rows との対応関係がありそうにも見えます。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。

おっしゃるとおりに感じていて、自分もrowとrowsがあるとき、rowはrowsの要素か、rowsの要素と型が同じと考えるのでrow_indexの方が良いと感じます。

result = []
for row_chars in rows:
result.extend(row_chars)
return "".join(result)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result 自体が返り値でないことは少し引っかかりましたが、4行なので今回は問題ないと思いました。

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.

3 participants