Question: IN PYTHON Inputs targetWords: A list of possible ninja words - e.g.. [Sun, Moon, Star, Planet] sentence: A target sentence which may contain ninja words
![e.g.. ["Sun", "Moon", "Star", "Planet"] sentence: A target sentence which may contain](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f07a1f6d3b6_93466f07a1ee6639.jpg)

Inputs targetWords: A list of possible ninja words - e.g.. ["Sun", "Moon", "Star", "Planet"] sentence: A target sentence which may contain ninja words Sentences will contain Ascll characters Aa-Zz, spaces, and asterisks e.g. "All the stars under the sky twinkle in slo mo on a clear night" Output Determine the score of the uncovered ninja words according to the following rules: 1 point for every ninja word found - 1 additional point for each ninja star contained in the word o "nin ja" 1 point "k*n ja" 3 points - Each ninja word should only be counted once per sentence. If a ninja word appears multiple times, only count the instance which gives the most points Example 1 - targetwords: [-5un", "Moon", "Star". -Planet'] - sentence: "All the stars under the sky twinkle in slo mo on a clear night" - Analysis: The target sentence contains 2 ninja words: - "sun", in "stars under" -. "Moon", in "slo mo on" - The word "Star" is in the sentence, but it is NOT a ninja word. because it is not split up by a space: - Each ninja word is worth 1 point for a total of 2 . - Retumz targetWords: ["Water", "Sea", "Beach", "Lake", "Shells"] sentence: "She sells she *lls on the shore for two sand dollar* each" Analysis: The first ninja star lets us find the word "shells", when we replace "*" with a space. The second ninja star allows us to find 2 additional ninja words. If we replace the * with an "s", "dollars each" contains "sea". If we replace the * with a "b", "dollarb each" contains "beach". - Each ninja word we've found has exactly one star in it, meaning each word is worth 2 points, for a total of 6 points. - Found words: o She*lls She s "Shells" - Dollar* each Dollarb each "Beach" - Dollar* each Dollars each "Sea
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
