Using python solve the given problems: Problem: In USA it is always the military officer's main worry to order his soldiers on parade correctly. Luckily, ordering soldiers is not really such a...


Using python solve the given problems:<br>Problem: In USA it is always the military officer's main worry to order his<br>soldiers on parade correctly. Luckily, ordering soldiers is not really such a<br>problem. If a platoon consists of n men, all of them have different rank (from 1-<br>lowest to n - highest) and on parade they should be lined up from left to right in<br>increasing order of rank.<br>Sounds simple, doesn't it? Well, Sgt Johnny thought the same, until one day he<br>was faced with a new command. He soon discovered that his elite commandos<br>preferred to do the fighting, and leave the thinking to their superiors. So, when<br>at the first rollcall the soldiers lined up in fairly random order it was not because<br>of their lack of discipline, but simply because they couldn't work out how to form<br>a line in correct order of ranks. Sgt Johnny was not at all amused, particularly as<br>he soon found that none of the soldiers even remembered his own rank. Over the<br>years of service every soldier had only learned which of the other soldiers were<br>his superiors. But Sgt Johnny was not a man to give up easily when faced with a<br>true military challenge. After a moment's thought a solution of brilliant<br>simplicity struck him and he issued the following order:

Extracted text: Using python solve the given problems: Problem: In USA it is always the military officer's main worry to order his soldiers on parade correctly. Luckily, ordering soldiers is not really such a problem. If a platoon consists of n men, all of them have different rank (from 1- lowest to n - highest) and on parade they should be lined up from left to right in increasing order of rank. Sounds simple, doesn't it? Well, Sgt Johnny thought the same, until one day he was faced with a new command. He soon discovered that his elite commandos preferred to do the fighting, and leave the thinking to their superiors. So, when at the first rollcall the soldiers lined up in fairly random order it was not because of their lack of discipline, but simply because they couldn't work out how to form a line in correct order of ranks. Sgt Johnny was not at all amused, particularly as he soon found that none of the soldiers even remembered his own rank. Over the years of service every soldier had only learned which of the other soldiers were his superiors. But Sgt Johnny was not a man to give up easily when faced with a true military challenge. After a moment's thought a solution of brilliant simplicity struck him and he issued the following order: "men, starting from the left, one by one, do: (step forward; go left until there is no superior to the left of you; get back in line).". This did indeed get the men sorted in a few minutes. The problem was solved. for the time being. The next day, the soldiers came in exactly the same order as the day before, and had to be rearranged using the same method. History repeated. After some weeks, Sgt Johnny managed to force each of his soldiers to remember how many men he passed when going left, and thus make the sorting process even faster. Input: 1 010 Output: 213
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here