frontAgain(s)
that will return True if the
first 2 chars in the string also appear at the end of the string, such as with "edited".
frontAgain("edited") → True frontAgain("edit") → False frontAgain("ed") → True
teaParty(tea, candy)
that will return the int outcome of the party as either,
bad=0, good=1, or great=2. A party is good (1) if both tea and candy are at least 5. However,
if either tea or candy is at least double the amount of the other one, the party is great (2).
However, in all cases, if either tea or candy is less than 5, the party is always bad (0).
teaParty(6, 8) → 1 teaParty(3, 8) → 0 teaParty(20, 6) → 2
getSandwich(s)
that will return the string that is between the first and
last appearance of "bread" in the given string, or return the empty string "" if there
are not two pieces of bread.
getSandwich("breadjambread") → "jam" getSandwich("xxbreadjambreadyy") → "jam" getSandwich("xxbreadyy") → ""
blackjack(player, dealer)
that
returns whichever value is nearest to 21 without going over. Return 0 if they both go over.
blackjack(19, 21) → 21 blackjack(21, 19) → 21 blackjack(19, 22) → 19
xyBalance(s)
that will return True if the given string is xy-balanced.
xyBalance("aaxbby") → True xyBalance("aaxbb") → False xyBalance("yaaxbb") → False
tripleUp(t)
that will return True if the list contains,
somewhere, three increasing adjacent numbers like .... 4, 5, 6, ... or 23, 24, 25.
tripleUp([1, 4, 5, 6, 2]) → True tripleUp([1, 2, 3]) → True tripleUp([1, 2, 4]) → False
evenOdd(t)
that will return a list that contains the exact
same numbers as the given list, but rearranged so that all the even numbers come before all
the odd numbers. Other than that, the numbers can be in any order. You may modify and return
the given list, or make a new list.
evenOdd([1, 0, 1, 0, 0, 1, 1]) → [0, 0, 0, 1, 1, 1, 1] evenOdd([3, 3, 2]) → [2, 3, 3] evenOdd([2, 2, 2]) → [2, 2, 2]
canBalance(t)
that will return True if
there is a place to split the list so that the sum of the numbers on one side is equal to the
sum of the numbers on the other side.
canBalance([1, 1, 1, 2, 1]) → True canBalance([2, 1, 1, 2, 1]) → False canBalance([10, 10]) → True