File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11
11
daBcd -> capitalize a and c(dABCd) -> remove d (ABC)
12
12
"""
13
13
14
-
15
14
def abbr (a , b ):
15
+ """
16
+ >>> abbr("daBcd", "ABC")
17
+ True
18
+ >>> abbr("dBcd", "ABC")
19
+ False
20
+ """
16
21
n = len (a )
17
22
m = len (b )
18
23
dp = [[False for _ in range (m + 1 )] for _ in range (n + 1 )]
@@ -28,4 +33,7 @@ def abbr(a, b):
28
33
29
34
30
35
if __name__ == "__main__" :
31
- print (abbr ("daBcd" , "ABC" )) # expect True
36
+ # print(abbr("daBcd", "ABC")) # expect True
37
+ import doctest
38
+
39
+ doctest .testmod ()
Original file line number Diff line number Diff line change @@ -14,8 +14,20 @@ def __init__(self, N=None):
14
14
self .fib_array .append (self .fib_array [i - 1 ] + self .fib_array [i - 2 ])
15
15
elif N == 0 :
16
16
self .fib_array .append (0 )
17
+ print (self .fib_array )
17
18
18
19
def get (self , sequence_no = None ):
20
+ """
21
+ >>> Fibonacci(5).get(3)
22
+ [0, 1, 1, 2, 3, 5]
23
+ [0, 1, 1, 2]
24
+ >>> Fibonacci(5).get(6)
25
+ [0, 1, 1, 2, 3, 5]
26
+ Out of bound.
27
+ >>> Fibonacci(5).get(-1)
28
+ [0, 1, 1, 2, 3, 5]
29
+ []
30
+ """
19
31
if sequence_no != None :
20
32
if sequence_no < len (self .fib_array ):
21
33
return print (self .fib_array [: sequence_no + 1 ])
@@ -46,3 +58,7 @@ def get(self, sequence_no=None):
46
58
print ("\n Invalid input, please try again." )
47
59
except NameError :
48
60
print ("\n ********* Invalid input, good bye!! ************\n " )
61
+
62
+ import doctest
63
+
64
+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments