-
Write 3 string literals (NOT A SEPARATE FUNCTION), like so:
Remember, we can use 'single-quoted strings' and """triple-quoted strings"""
a = # You write this
b = # You write this
c = # You write this
If I run the following code:
print("========")
print(a)
print("========")
print(b)
print("========")
print(c)
print("========")
It should output EXACTLY
=======
I "ate" the "so-called" "snacks"
=======
"can't won't didn't"
=======
"all's well that
ends on a new line"
=======
-
Write a function rotate(text, n). text is a string, n is an integer. This should return the result of rotating text n times, where a single rotation moves the first character to the back.
# ("ABCD", 1) -> "BCDA"
# ("oreos", 3) -> "osore"
# ("ABCD", 6) -> "CDAB"
-
Write a function isRotated(A, B). A and B are strings. This should return True if B could be a rotation of A, as defined by rotate(), and False otherwise.
# ("ABCD","ABCD") -> True
# ("ABCD","CDAB") -> True
# ("oreos","osore") -> True
# ("oreos","soore") -> False
# ("apples","oranges") -> False
-
Write a function findWord(text, word). text and word are both strings. This should return the index of the left-most position where word can be found in text. If word does not appear anywhere in text, return -1.
# ("athena", "hen") -> 2
# ("athena", "athena") -> 0
# ("athena", "orange") -> -1
-
Write a function findWordStartingAt(text, word, start). text and word are both strings, start is an integer. This should return the same thing as findWord, but it should only begin looking for the word from the character at text[start].
# ("red fish blue fish", "fish", 0) -> 4
# ("red fish blue fish", "fish", 5) -> 14
# ("red fish blue fish", "fish", 15) -> -1