반응형
The Feast of Many Beasts
All of the animals are having a feast! Each animal is bringing one dish. There is just one rule: the dish must start and end with the same letters as the animal's name. For example, the great blue heron is bringing garlic naan and the chickadee is bringing chocolate cake.
Write a function feast that takes the animal's name and dish as arguments and returns true or false to indicate whether the beast is allowed to bring the dish to the feast.
Assume that beast and dish are always lowercase strings, and that each has at least two letters. beast and dish may contain hyphens and spaces, but these will not appear at the beginning or end of the string. They will not contain numerals.
Solution:
def feast(beast: str, dish: str) -> bool:
return beast[0] == dish[0] and beast[-1] == dish[-1]
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0124. Regular Ball Super Ball (0) | 2023.01.24 |
---|---|
0123. Check same case (0) | 2023.01.23 |
0121. esreveR (0) | 2023.01.21 |
0120. Alphabet symmetry (0) | 2023.01.21 |
0119. Thinkful - Number Drills: Blue and red marbles (0) | 2023.01.19 |