7 kyu

String destroyer (plus extra credit)

363 of 563mkelty

Description:

Background:

You have a starting string of the lowercase alphabet, space-separated:

"a b c d e f g h i j k l m n o p q r s t u v w x y z"

Then you are given random sets of letters to throw against this string. For example:

{'e', 'B', 'F', 'i'}

Whenever there is a match (case sensitive), the letter in the original string is knocked out and replaced by an underscore. Using the random set above as an example would result in:

"a b c d _ f g h _ j k l m n o p q r s t u v w x y z"

Implementation

Write a function destroyer(input_sets) that takes input as a tuple of one or more of these random character sets and returns the alphabet formatted as shown, with underscores showing where matches knocked out a letter.

For example:

>>> input_sets = ({'A', 'b'}, {'d', 'C', 'b'})
>>> destroyer(input_sets)
>>> "a _ c _ e f g h i j k l m n o p q r s t u v w x y z"

Extra credit question:

If the average random set thrown at the lowercase alphabet is ten (10) characters long (same rules as above, uppercase and lowercase letters only), then how many random sets - on average - do you have to throw at the alphabet in order to be left with only underscores?

Fundamentals

More By Author:

Check out these other kata created by mkelty

Stats:

CreatedJan 8, 2017
PublishedJan 8, 2017
Warriors Trained1023
Total Skips51
Total Code Submissions2370
Total Times Completed563
Python Completions363
Rust Completions216
Total Stars11
% of votes with a positive feedback rating87% of 168
Total "Very Satisfied" Votes134
Total "Somewhat Satisfied" Votes25
Total "Not Satisfied" Votes9
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • mkelty Avatar
  • imjasonmiller Avatar
  • tachyonlabs Avatar
  • Keozon Avatar
  • Voile Avatar
  • saudiGuy Avatar
Ad