FAQ on Backend - War Challenge

This article helps you understand the War challenge better. Below are questions asked by developers such as yourself.  

Frequently Asked Questions

1.   Can you explain sample input-output #3 from the problem PDF.  INPUT - FALICORNIA_ATTACK 250H 50E 20AT 15SG 

At the first we apply the Power Rule and Like to Like Rule to match the attack. LENGABURU needs to deploy only half the size of FALICORNIA as per the Power Rule. Thus applying these 2 rules will get

100H 25E 10AT 5SG

Now at this point of time Lengaburu has not matched Horses and Sling Guns of Falicornia. And Lengaburu has only 25 Elephant’s left. Lengaburu needs 25 Horses to match the remaining 50 Horses of Falicornia, and 3 Sling Guns to match the remaining 5 Sling Guns of Falicornia. Here we apply the rule #3. So we substitute 25 Horses needed by Lengaburu with 13 of its elephants. Now the status of battalion is.

100H 38E 10AT 5SG

At this point of time only Sling Guns are left to be matched for Lengaburu. But it is unable to substitute 3 Sling Guns with anything as Armoured Tanks are now exhausted. Even though 12 Elephant are available, it can’t be used as Elephants can only replace its adjacent battalions Horses and Armoured Tanks. Hence the final status is:  

LOSES 100H 38E 10AT 5SG

2. If Falicornia has an attack -  FALICORNIA_ATTACK 0H 0E 20AT 15SG then what would be the output?

The output will be:

LOSES 0H 0E 10AT 5SG

The order of it is from lower battalion to higher battalion. So 10AT matches 20 AT in the first round and 5SG can only match 10SG from the attacker. In the next round you cannot use Elephants as it can only replace its adjacent battalions.

3. How to handle edges cases like FALICORNIA_ATTACK 0H 0E 0AT 0SG?

You should throw an error in this case as the attack never happened.

4. Can a battalion be substituted by lower as well as higher ranked battalion at the same time?

Yes. But the priority of substitution goes to the lower ranked battalion first and if they are exhausted then the higher ranked battalion can be substituted.

For e.g Consider a case - FALICORNIA_ATTACK 150H 96E 26AT 6SG

Here after applying first 2 rules, the status will be 

75H 48E 10AT 3SG 

At this point we have to match 6 more of Falicornia’s Armoured Tanks. For that as per Power Rule, Lengaburu needs 3 Armoured Tanks but all of it is exhausted. They have 2 Elephants and 2 Sling Guns left. First we have to substitute with the Elephants, and the status now will be 

75H 50E 10AT 3SG  - (2 Elephants replace 1 Armoured Tank, so 2 more Tanks need to be matched)

Then we substitute with the Sling Guns. In this case we need only one Sling Gun to replace 2 Armoured Tanks. So the status now will be:

WINS 75H 50E 10AT 4SG

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us