We post one challenging problem here every week. Solution due is 11:59 PM every Friday. We offer awards to two responders. 1. The first one with the right solution. 2. The correct solution with fewest code statements.
If we get only one correct solution, we will skip the award for the fewest code statements.
You need to create an account in this club in order to participate in this competition. The solution can use one of these three languages: Java, Python, JavaScript. You can submit your solution to this topic. Make sure your name and email account are in the end of the solution.
If you want that we indent your code correctly, please submit your code to this challenge along with a screenshot of your code in your IDE or your code file as an attachment. Remember you still need to submit your code as text here. Thanks for your participation.
Problem: Tom likes playing with words. He keeps a list of 50 words he likes the most. Now he asks the user to input a string. He will use the characters inputted by the user to form the exact words he has in his list. He can only use the characters that the user inputs. The order of the character in the input is not considered. Can you help Tom write an method to figure out how many words that the input string can form? If the string can form the same words multiple time, count them multiple times. If the word needs three but the input has only one, for an example, that does not count. If it cannot form any word in Tom’s list, return 0. Also please help Tom create his lovely 50 words (no word is just one character, like a for an example) list. All words are Case sensitive
Question: Are the fifty words also given as input or are they added to the code initially.
You create that list in the beginning of your code
Do the characters get deleted after the word is formed, or do we use the same batch of characters to try to form all the words?
Example 1 (deleting the letters):
Your letters: A, N, D, G, H
Word: “and”
Letters left for the next word: G, H
Example 2 (same letters for each word):
Your letters: A, N, D, G, H
Word: “and”
Letters left for the next word: A, N, D, G, H
Which example should we follow?
No they do not get deleted. When you use them to form a word, you retrieve them from the input. Every time you just check if the input can form that word and how many of this word can be formed using the input. Pay attention to upper case and lower case though. It is case 2 in your question but the input may be good for two “And” then you need count 2 for this situation. After that, all characters are returned back to the pool for next word. Case sensitive and case sensitive please
This is my submission for the challenge.
https://docs.google.com/document/d/1sQ-Yw_nNm0yquSCPQ6ZoWDcTFPK1GeFyTCYBzcxIvyc/edit?usp=sharing
Congratulation to Ryan for the Quickest Problem Solver award