about | help | code help+videos | done | prefs |
(MEDIUM) Given a String made up of different words, re-arrange the order of the words such that all the even-indexed words (the first word has index 0) appear at the end of the output in reversed order. So if the input has 10 words in index positions "0 1 2 3 4 5 6 7 8 9", the output order will be "1 3 5 7 9 8 6 4 2 0". A "word" for purposes of this problem is any non-space character separated by spaces from other words. So "words" can and will include punctuation, digits and the like. Precondition: only one space at a time between the words in the input. HINT Use the split(" ") method of the String class to change a String into an array of Strings, based on the spaces in the original. Also consider that re-arranging this array is not ideal given how much things have to move around.apcsaEncryptRearrangeWords("eat it") → "it eat" apcsaEncryptRearrangeWords("0 1 2 3 4 5 6 7 8 9") → "1 3 5 7 9 8 6 4 2 0" apcsaEncryptRearrangeWords("First shalt thou take out the Holy Pin. Then, shalt thou count to three. No more. No less. Three shalt be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, nor either count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then, lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in My sight, shall snuff it.") → "shalt take the Pin. shalt count three. more. less. shalt the thou count, the of counting be Four thou count, either thou excepting thou proceed three. is out. the three, the number, reached, lobbest thy Hand of towards foe, being in sight, snuff it. shall My naughty who, thy Antioch Grenade Holy thou then, be third being number Once right Five to then that two, count nor not shalt three. shall the number and shalt number be Three No No to thou Then, Holy out thou First" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy