Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions part-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@
# the appropriate comment.

# factorial



# reverse

def factorial(n):
if not n:
return False
if n==1 or n==0:
return n
else:
facty = factorial(n-1)
result = n*facty
return result


def reverse(string):
if len(string) == 0:
return ''
else:
return reverse(string[1:]) + string[0]


# bunny

def bunny(count):
bunny = count * 2
return bunny


# is_nested_parens


def is_nested_parens(thing):
if not thing:
return
is_nested_parens(thing[thing.find('(', 1):thing.rfind(')', 0, len(thing)-1)+1])
return(thing)
32 changes: 25 additions & 7 deletions part-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@
# the appropriate comment.

# search



# is_palindrome

def search(array, query):
if not array:
return False
if array[0] == query:
return True
return search(array[1:], query)


def is_palindrome(text):
if not text:
return True
if len(text) < 2 :
return True
if text[0] != text[-1]:
return False
return is_palindrome(text[1:-1])


# digit_match


def digit_match(num1, num2):
if not num1 or not num2:
return False
matching_pairs = 0
matches = []
while num1[-1] == num2[-1]:
matches = matching_pairs - 1
return digit_match(num1, num2)
return matches