Cody

# Problem 45454. Most Frequent Word - 01

Solution 2211405

Submitted on 14 Apr 2020 by Binbin Qi
• Size: 34
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
str = 'Bran thought about it. Can a man still be brave if he is afraid? That is the only time a man can be brave, his father told him.'; assert(isequal(freq_word_2(str),{'a'}))

2   Pass
str = 'Everything in this world is magic, except to the magician.'; assert(isequal(freq_word_2(str),{'Everything'}))

3   Pass
str = 'When you are suffering, that is when you are most real.'; assert(isequal(freq_word_2(str),{'are'}))

4   Pass
str = 'We humans are alone in this world for a reason. We murdered and butchered anything that challenged our primacy.'; assert(isequal(freq_word_2(str),{'We'}))

5   Pass
str = 'A greyhound is a racing dog. Spends its life running in circles, chasing a bit of felt made up like a rabbit. One day, we took it to the park. Our dad had warned us how fast that dog was, but we could not resist. So, my brother took off the leash, and in that instant, the dog spotted a cat. I imagine it must have looked just like that piece of felt. He ran. Never saw a thing as beautiful as that old dog running. Until, at last, he finally caught it. And to the horror of everyone, he killed that little cat. Tore it to pieces. Then he just sat there, confused. That dog had spent its whole life trying to catch that thing. Now it had no idea what to do.'; assert(isequal(freq_word_2(str),{'that'}))

6   Pass
str = 'High in the halls of the kings who are gone.Jenny would dance with her ghosts.The ones she had lost and the ones she had found...And the ones who had loved her the most,The ones who had been gone for so very long,She couldnt remember their names,They spun her around on the damp old stones,Spun away all her sorrow and pain,And she never wanted to leave, never wanted to leave,Never wanted to leave, never wanted to leave,They danced through the day,And into the night through the snow that swept through the hall,From winter to summer then winter again,Till the walls did crumble and fall,And she never wanted to leave, never wanted to leave,Never wanted to leave, never wanted to leave,And she never wanted to leave, never wanted to leave,Never wanted to leave, never wanted to leave,!!High in the halls of the kings who are gone;;Jenny would dance with her ghosts,The ones she had lost and the ones she had found,And the ones,Who had loved her the most'; assert(isequal(freq_word_2(str),{'the'}))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!