File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1111daBcd -> capitalize a and c(dABCd) -> remove d (ABC)
1212"""
1313
14-
1514def abbr (a , b ):
15+ """
16+ >>> abbr("daBcd", "ABC")
17+ True
18+ >>> abbr("dBcd", "ABC")
19+ False
20+ """
1621 n = len (a )
1722 m = len (b )
1823 dp = [[False for _ in range (m + 1 )] for _ in range (n + 1 )]
@@ -28,4 +33,7 @@ def abbr(a, b):
2833
2934
3035if __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):
1414 self .fib_array .append (self .fib_array [i - 1 ] + self .fib_array [i - 2 ])
1515 elif N == 0 :
1616 self .fib_array .append (0 )
17+ print (self .fib_array )
1718
1819 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+ """
1931 if sequence_no != None :
2032 if sequence_no < len (self .fib_array ):
2133 return print (self .fib_array [: sequence_no + 1 ])
@@ -46,3 +58,7 @@ def get(self, sequence_no=None):
4658 print ("\n Invalid input, please try again." )
4759 except NameError :
4860 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