Skip to content

Commit

Permalink
# Fun with lists: length
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent 41d9c30 commit 11dd1fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions kyu_7/fun_with_lists_length/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Fun with lists: length."""
5 changes: 4 additions & 1 deletion kyu_7/fun_with_lists_length/length.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Fun with lists: length
Solution for -> Fun with lists: length.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def length(head) -> int:
"""
Length function.
The method length, which accepts a linked list
(head), and returns the length of the list.
:param head:
Expand Down
20 changes: 12 additions & 8 deletions kyu_7/fun_with_lists_length/node.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
"""
Node class for -> Fun with lists: length
Node class for -> Fun with lists: length.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


class Node:
"""
The linked list
"""
"""The linked list."""

def __init__(self, data, n_next=None):
self._data = data
self._next = n_next

@property
def next(self):
"""
Get next
Get next.
:return:
"""
return self._next

@next.setter
def next(self, n_next=None) -> None:
"""
Get next
Get next.
:param n_next:
:return:
"""
Expand All @@ -33,15 +35,17 @@ def next(self, n_next=None) -> None:
@property
def data(self):
"""
Get data
Get data.

Check warning on line 39 in kyu_7/fun_with_lists_length/node.py

View check run for this annotation

Codecov / codecov/patch

kyu_7/fun_with_lists_length/node.py#L39

Added line #L39 was not covered by tests
:return:
"""
return self._data

@data.setter
def data(self, data) -> None:
"""
Get data
Get data.

Check warning on line 48 in kyu_7/fun_with_lists_length/node.py

View check run for this annotation

Codecov / codecov/patch

kyu_7/fun_with_lists_length/node.py#L48

Added line #L48 was not covered by tests
:param data:
:return:
"""
Expand Down
12 changes: 5 additions & 7 deletions kyu_7/fun_with_lists_length/test_length.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Fun with lists: length
Test for -> Fun with lists: length.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand Down Expand Up @@ -28,14 +29,11 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class LengthTestCase(unittest.TestCase):
"""
Testing length function
"""
"""Testing length function."""

def test_length_none(self):
"""
Testing length function
where head = None
Testing length function where head = None.
The method length, which accepts a linked list
(head), and returns the length of the list.
Expand All @@ -57,7 +55,7 @@ def test_length_none(self):

def test_length(self):
"""
Testing length function
Testing length function.
The method length, which accepts a linked list
(head), and returns the length of the list.
Expand Down

0 comments on commit 11dd1fd

Please sign in to comment.