Menu

📰
0

Random Scrambles

DEV Community: perl·Zapwai·about 1 month ago
#FZGy7YPe
#dev#class#word#scramble#paragraph#article
Reading 0:00
15s threshold

Week 370 My Solutions Task 1 : Popular Word (By M. Anwar) You are given a string paragraph and an array of the banned words. Write a script to return the most popular word that is not banned. It is guaranteed there is at least one word that is not banned and the answer is unique. The words in paragraph are case-insensitive and the answer should be in lowercase. The words can not contain punctuation symbols. For frequency of words I immediately plan to use a hash. My only hangup on this one was when the input paragraph was not space separated but used punctuation marks instead. This could be more robust, but that's an abnormal input. I turn everything lowercase, check for spaces, strip out the punctuation marks, and put the word count in the hash %h. Then we ignore banned words.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More