7 kyu

The Baby Years I - Baby Counting

244 of 725PG1

Description:

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:

"baby" = 1
"abby" = 1
"babybaby" = 2
"Why the hell are there so many babies?!" = 1
"Anyone remember life before babies?" = 1
"Happy babies boom ba by?" = 2

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

'none here' = "Where's the baby?!" '' = "Where's the baby?!"

Fundamentals
Strings

More By Author:

Check out these other kata created by PG1

Stats:

CreatedOct 19, 2018
PublishedOct 19, 2018
Warriors Trained1364
Total Skips60
Total Code Submissions4173
Total Times Completed725
JavaScript Completions244
Python Completions307
Kotlin Completions196
Total Stars17
% of votes with a positive feedback rating92% of 213
Total "Very Satisfied" Votes184
Total "Somewhat Satisfied" Votes25
Total "Not Satisfied" Votes4
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • PG1 Avatar
  • suic Avatar
  • kdmatrosov Avatar
  • FArekkusu Avatar
  • Admiraal Avatar
  • farhanaditya Avatar
Ad