Yuddh - At War!!
Description:
There will be no peace talk, no negotiations, there will only be Yuddh(War).
General, here you have troop composition of two armies given to you as 2 lists. These armies consist of equal number of regiments.
Each element in the list represent a regiment, the numerical value of each element is the number of soldiers in the respective regiment. Note, the length of the two armies will always be equal.
Now comes the interesting stuff,
The power of 1 soldier in a regiment = 2^(Position of regiment in the army list)
Then power of entire regiment = Number of soldiers in regiment X Power of 1 Soldier
For example: [2000, 400]
Here, Power of 1 soldier of Regiment 1 = 2^1 = 2,
Then the Power of entire Regiment 1 = 2000 X 2 = 4000
Similarly, Power of 1 soldier of Regiment 2 = 2^2 = 4,
Then the Power of entire Regiment 2 = 400 X 4 = 1600
So, the power of entire army = 4000 + 1600 = 5600
Now, your task is to find which army will win the battle based on crude power and the winner's remaining crud power.
Example: Army_1 = [2000, 400]; Army_2 = [1400,600]
Power of Army_1 = (2000 X 2) + (400 X 4) = 5600
Power of Army_2 = (1400 X 2) + (600 X 4) = 5200
Battle: Army_1 > Army_2; Army_1 Won; 400 soldiers left
Output: "Army_1:400"
In case of a tie i.e. Power of Army_1 = Power of Army_2,
Output: "Tie"
-----------------------------------------------------------x-----------------------------------------------------------
This is my first Kata, hope you enjoyed coding it :) Kindly provide me your suggestions in the comments. Bye.
Similar Kata:
Stats:
Created | Jun 14, 2022 |
Warriors Trained | 40 |
Total Skips | 2 |
Total Code Submissions | 91 |
Total Times Completed | 33 |
Python Completions | 33 |
Total Stars | 1 |
% of votes with a positive feedback rating | 80% of 22 |
Total "Very Satisfied" Votes | 15 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 22 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |