Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step the word having the most letters, among the words not already shifted in an earlier step, is taken out and placed at the extreme right end of the line; if two words are equally long, the one that comes earlier in alphabetical order is taken first. Every other element keeps its relative position, and the machine stops once every word has been shifted.
Input: harbour 35 violin 68 candle 12 oak 59.
In Step 2 of the above arrangement, which element is third from the right end?

Competition practiceInput-Output
  • A59
  • Bharbour
  • Coak
  • D68

Step-by-Step Solution

Letter counts: harbour 7, violin 6, candle 6, oak 3. Violin and candle are equally long, so the tie-break sends candle out first. Step 1: 35 violin 68 candle 12 oak 59 harbour. Step 2: 35 violin 68 12 oak 59 harbour candle. From the right end of Step 2: candle, harbour, 59 — so 59 is third. Counting one place short gives harbour, one place too far gives oak, and counting from the left end instead gives 68.
Answer: A) 59

Master this topic in 30 minutes a day.

Don't just memorise the answer — build a daily practice habit.

Practice 5 Similar Questions Free →

All Input-Output practice questions

More Input-Output practice

A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…