Skip to content

Add two numbers#2

Open
SuperHotDogCat wants to merge 7 commits intoarai60from
add_two_numbers
Open

Add two numbers#2
SuperHotDogCat wants to merge 7 commits intoarai60from
add_two_numbers

Conversation

@SuperHotDogCat
Copy link
Copy Markdown
Owner

No description provided.

@SuperHotDogCat
Copy link
Copy Markdown
Owner Author

あ、phase2のところでorder -> digit 同じものを意味する言葉を混在させないとあるんですが, phase1を書いている途中で, 方針が合わないなと思って消してしまった別の関数を生やしていてその中でdigitという名前を使っていたので直したってだけです

@SuperHotDogCat
Copy link
Copy Markdown
Owner Author

あとphase3で急ぐあまりコメントをしてなかったですね。

@SuperHotDogCat
Copy link
Copy Markdown
Owner Author

@@ -0,0 +1,51 @@
# Definition for singly-linked list.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Linked listをintに変換しないでできますか?

Copy link
Copy Markdown

@liquo-rice liquo-rice left a comment

Choose a reason for hiding this comment

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

いいと思います。


class Solution:
def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
sentinel = ListNode()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

dummy_headっていう名前もありですね。sentinelなのは確かにそうなんですが、どんなsentinelなのか名前だけからは分からないと思います。

class Solution:
def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
sentinel = ListNode()
tail_node = sentinel
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tailだけもありです。ListNodeであることから、tail nodeであることは明らかですよね。

tail_node = sentinel
carry = 0
while l1 or l2 or carry:
add_value = carry
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

totalとかはどうでしょう。addを使うならadded_valueなら英語の響きがいいです。本当はsumが使いたいですよね…

Copy link
Copy Markdown

@nodchip nodchip left a comment

Choose a reason for hiding this comment

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

phase 5 よいと思います。

@rihib rihib mentioned this pull request Aug 6, 2024
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