id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2022_04_21_HL_returnFive
prev  |  next  |  chance

Write a method that accepts a string 'str' and returns a new string made up of only the five-letter "words" found in 'str'. A five-letter "word" is collection of non-space symbols surrounded by spaces. Being at the front or end of the string also counts as a space. So, for "Seven people were running on the roads", you would return "Seven roads". For "Flows down the round with a hound" you would return "Flows round hound". Remember, ANY non-space character counts towards the five characters. For "This, That, and the other thing." You would return "This, That, other" ("thing." was NOT returned because of the "." making it SIX symbols.) Note: There will be a trailing space unless you return an empty string. Look at the test data for further examples.


test2022_04_21_HL_returnFive("No five letter words!") → ""
test2022_04_21_HL_returnFive("I WAS sick -- sick unto death with that long agony; and when they at length unbound me, and I was permitted to sit, I felt that my senses were leaving me. The sentence -- the dread sentence of death -- was the last of distinct accentuation which reached my ears. After that, the sound of the inquisitorial voices seemed merged in one dreamy indeterminate hum. It conveyed to my soul the idea of revolution -- perhaps from its association in fancy with the burr of a mill wheel. This only for a brief period; for presently I heard no more. Yet, for a while, I saw; but with how terrible an exaggeration! I saw the lips of the black-robed judges. They appeared to me white -- whiter than the sheet upon which I trace these words -- and thin even to grotesqueness; thin with the intensity of their expression of firmness -- of immoveable resolution -- of stern contempt of human torture. I saw that the decrees of what to me was Fate, were still issuing from those lips. I saw them writhe with a deadly locution. I saw them fashion the syllables of my name; and I shuddered because no sound succeeded. I saw, too, for a few moments of delirious horror, the soft and nearly imperceptible waving of the sable draperies which enwrapped the walls of the apartment. And then my vision fell upon the seven tall candles upon the table. At first they wore the aspect of charity, and seemed white and slender angels who would save me; but then, all at once, there came a most deadly nausea over my spirit, and I felt every fibre in my frame thrill as if I had touched the wire of a galvanic battery, while the angel forms became meaningless spectres, with heads of flame, and I saw that from them there would be no help. And then there stole into my fancy, like a rich musical note, the thought of what sweet rest there must be in the grave. The thought came gently and stealthily, and it seemed long before it attained full appreciation; but just as my spirit came at length properly to feel and entertain it, the figures of the judges vanished, as if magically, from before me; the tall candles sank into nothingness; their flames went out utterly; the blackness of darkness supervened; all sensations appeared swallowed up in a mad rushing descent as of the soul into Hades. Then silence, and stillness, night were the universe.") → "death dread death which ears. After that, sound fancy brief heard more. white sheet which trace these words their stern human Fate, still those lips. name; sound sable which walls seven first white would then, once, there every fibre frame while angel forms heads there would help. there stole note, sweet there their night "
test2022_04_21_HL_returnFive("The thousand injuries of Fortunato I had borne as I best could, but when he ventured upon insult I vowed revenge. You, who so well know the nature of my soul, will not suppose, however, that I gave utterance to a threat. At length I would be avenged; this was a point definitively settled — but the very definitiveness with which it was resolved precluded the idea of risk. I must not only punish but punish with impunity. A wrong is unredressed when retribution overtakes its redresser. It is equally unredressed when the avenger fails to make himself felt as such to him who has done the wrong.") → "borne vowed soul, would point which risk. wrong fails "

...Save, Compile, Run (ctrl-enter)

public String test2022_04_21_HL_returnFive(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy