Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

IN PYTHON image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

How is psychology a science?

Answered: 1 week ago