Return the number (count) of vowels in the given string.
We will consider a, e, i, o, u as vowels for this Kata (but not y).
The input string will only consist of lower case letters and/or spaces.
문장 안에 모음이 들어가면 숫자를 늘려주는 간단한 문제이다.
def get_count(sentence): count = 0 for i in sentence: if i in 'aeiou': count +=1 return count
두번째 문제는
cakes({flour: 500, sugar: 200, eggs: 1}, {flour: 1200, sugar: 1200, eggs: 5, milk: 200})
cakes({apples: 3, flour: 300, sugar: 150, milk: 100, oil: 100}, {sugar: 500, flour: 2000, milk: 2000})
위 답은 2이고 아래 답은 0이다. 즉 레시피와 재료를 가지고 만들 수 있는 최대 개수를 만들어야 한다.
def cakes(recipe, available): el = [] for i in recipe: if i in available: el.append(available[i]/recipe[i]) else: return 0 return min(el)
만약 i가 available 안에 존재하면 빈 리스트에 가능한 양에서 레시피 양을 나눈 값을 집어넣은 후 그 값들 중에서 가장 작은 수를 리턴한다.