You've had a baby.

Well done. Nice isn't it? Life destroying... but in a good way.

Part of your new routine is lying awake at night worrying that you've either lost the baby... or that you have more than 1!

Given a string of words (x), you need to calculate how many babies are in it. To count as a baby you must have all of the letters in baby ('b', 'a', 'b', 'y'). That counts as 1. They do not need to be in order in the string. Upper and lower case letters count.

Examples:

If there are no babies in the string - you lost the baby!! Return a different value, as shown below:

```if-not:kotlin
'none here' = "Where's the baby?!"
'' = "Where's the baby?!"
```

```if:kotlin 
"none here" = null
"" = null
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def baby_count(x):
	

Solutions:
def baby_count(x):
	x = x.lower()
	return min(x.count('a'), x.count('b') // 2, x.count('y')) or "Where's the baby?!"


from collections import Counter

def baby_count(x):
	c = Counter(x.lower())
	return min(c['b'] // 2, c['a'], c['y']) or "Where's the baby?!"


baby_count = lambda x: min((x.lower().count(e) // (2 - (e != 'b')) for e in 'bay')) or "Where's the baby?!"


def baby_count(x):
	x = x.lower()
	nb = min(x.count('a'), x.count('y'), x.count('b') // 2)
	return nb if nb else "Where's the baby?!"


def baby_count(x):
	b = 0
	a = 0
	y = 0
	for c in x.upper():
		if c == 'B':
			b += 1
		elif c == 'A':
			a += 1
		elif c == 'Y':
			y += 1
	count = min(a, b // 2, y)
	return count if count > 0 else "Where's the baby?!"


def baby_count(x):
	T = [x.lower().count(e) // (2 if e == 'b' else 1) for e in 'bay']
	print(T)
	return min(T) if min(T) != 0 else "Where's the baby?!"


def baby_count(x):
	x = x.lower()
	babies = 0
	letters = [x.count('b'), x.count('a'), x.count('y')]
	while min(letters) > 0 and letters[0] > 1:
		letters[0] -= 2
		letters[1] -= 1
		letters[2] -= 1
		babies += 1
	if babies == 0:
		return "Where's the baby?!"
	else:
		return babies


def baby_count(x):
	s = x.lower()
	a = s.count('a')
	b = s.count('b')
	d = b // 2
	y = s.count('y')
	z = [a, d, y]
	m = min(z)
	if m == 0:
		return "Where's the baby?!"
	else:
		return m