7 kyu
Survive the attack
397 of 2,556EvaRD
Description:
Given two Arrays in which values are the power of each soldier, return true if you survive the attack or false if you perish.
CONDITIONS
- Each soldier attacks the opposing soldier in the same index of the array. The survivor is the number with the highest value.
- If the value is the same they both perish
- If one of the values is empty(different array lengths) the non-empty value soldier survives.
- To survive the defending side must have more survivors than the attacking side.
- In case there are the same number of survivors in both sides, the winner is the team with the highest initial attack power. If the total attack power of both sides is the same return true.
- The initial attack power is the sum of all the values in each array.
EXAMPLES
attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4, 6, 8 ]
//0 survivors 4 survivors
//return true
attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4 ]
//2 survivors (16 damage) 2 survivors (6 damage)
//return false
attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4, 0, 8 ]
//1 survivors 3 survivors
//return true
Arrays
Similar Kata:
Stats:
Created | Oct 17, 2022 |
Published | Oct 17, 2022 |
Warriors Trained | 6934 |
Total Skips | 150 |
Total Code Submissions | 23889 |
Total Times Completed | 2556 |
Java Completions | 397 |
Python Completions | 937 |
TypeScript Completions | 98 |
C# Completions | 216 |
JavaScript Completions | 930 |
F# Completions | 8 |
Prolog Completions | 8 |
C Completions | 49 |
Total Stars | 135 |
% of votes with a positive feedback rating | 89% of 341 |
Total "Very Satisfied" Votes | 279 |
Total "Somewhat Satisfied" Votes | 47 |
Total "Not Satisfied" Votes | 15 |
Total Rank Assessments | 13 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |