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
13 changes: 11 additions & 2 deletions recursive_count_th/count_th.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
'''
def count_th(word):

# TBC
# Verify if the length of the word is not less than "th"; else, it contains it

pass
if len(word) < len('th'):
return 0

#Furthermore, verify if the first two letters equals "th", return 1
elif word[:2] == 'th':
return count_th(word[2:]) + 1

#Else, proceed with the next letter of the word
else:
return count_th(word[1:])
23 changes: 22 additions & 1 deletion robot_sort/robot_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,28 @@ def sort(self):
Sort the robot's list.
"""
# Fill this out
pass
self.set_light_on()

while self.light_is_on():
self.set_light_off()

while self.can_move_right():
self.move_right()

if self.compare_item() == 1:
self.swap_item()
self.set_light_on()

while self.can_move_left():
self.swap_item()
self.move_left()

if self.compare_item() == -1:
self.swap_item()
self.set_light_on()
self.move_right()
self.swap_item()
self.move_left()


if __name__ == "__main__":
Expand Down