Create 0006-zigzag-conversion.md - #61
Conversation
| break | ||
| yield s[s_index] | ||
|
|
||
| return "".join(generate_zigzag()) |
There was a problem hiding this comment.
行ごとに文字を返していく方法だと理解しました。一つのサイクルには 0 と numRows - 1 以外の行の文字は二つずつあるんですね。この点には注目できなくて参考になります。
関数名ですが、zigzag を generate しているわけではないような気がしており、generate_rows などの方が近い気がしておりますがいかがでしょうか。
There was a problem hiding this comment.
関数名ですが、zigzag を generate しているわけではないような気がしており、generate_rows などの方が近い気がしておりますがいかがでしょうか。
確かにその通りですね... おっしゃるとおり、generate_rowsやgenerate_row_by_rowなどが適切に思えました。
|
Arai60 お疲れ様でした。 Grind75 に行かれるようでしたら、引き続きよろしくお願いいたします。 |
| if numRows == 1 or len(s) <= numRows: | ||
| return s | ||
|
|
||
| row = 0 |
There was a problem hiding this comment.
row_index など、行番号のニュアンスがあっても良いかなと思いました。row の場合、内容を読む前だと rows との対応関係がありそうにも見えます。
There was a problem hiding this comment.
ありがとうございます。
おっしゃるとおりに感じていて、自分もrowとrowsがあるとき、rowはrowsの要素か、rowsの要素と型が同じと考えるのでrow_indexの方が良いと感じます。
| result = [] | ||
| for row_chars in rows: | ||
| result.extend(row_chars) | ||
| return "".join(result) |
There was a problem hiding this comment.
result 自体が返り値でないことは少し引っかかりましたが、4行なので今回は問題ないと思いました。
この問題:https://leetcode.com/problems/zigzag-conversion/
本問でArai60おわり。
Grind75