Skip to content

[fixed] unused variable, standalone running, import doctest module #4673

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

Merged
merged 11 commits into from
Aug 28, 2021
3 changes: 3 additions & 0 deletions matrix/nth_fibonacci_using_matrix_exponentiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ def main():


if __name__ == "__main__":
import doctest

doctest.testmod()
main()
11 changes: 6 additions & 5 deletions matrix/spiral_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

def checkMatrix(a):
# must be
if type(a) == list and len(a) > 0:
if type(a[0]) == list:
if type(a) == tuple and len(a) > 0:
if type(a[0]) == tuple:
prevLen = 0
for i in a:
if prevLen == 0:
Expand All @@ -33,7 +33,7 @@ def spiralPrint(a):
if checkMatrix(a) and len(a) > 0:

matRow = len(a)
if type(a[0]) == list:
if type(a[0]) == tuple:
matCol = len(a[0])
else:
for dat in a:
Expand Down Expand Up @@ -64,5 +64,6 @@ def spiralPrint(a):


# driver code
a = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
spiralPrint(a)
if __name__ == "__main__":
a = ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12])
spiralPrint(a)
6 changes: 3 additions & 3 deletions other/fischer_yates_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import random


def FYshuffle(list):
for i in range(len(list)):
def fisher_yates_shuffle(data: list) -> list:
for _ in range(len(list)):
a = random.randint(0, len(list) - 1)
b = random.randint(0, len(list) - 1)
list[a], list[b] = list[b], list[a]
Expand All @@ -21,4 +21,4 @@ def FYshuffle(list):
strings = ["python", "says", "hello", "!"]
print("Fisher-Yates Shuffle:")
print("List", integers, strings)
print("FY Shuffle", FYshuffle(integers), FYshuffle(strings))
print("FY Shuffle", fisher_yates_shuffle(integers), fisher_yates_shuffle(strings))