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

Stats:

CreatedOct 17, 2022
PublishedOct 17, 2022
Warriors Trained6934
Total Skips150
Total Code Submissions23889
Total Times Completed2556
Java Completions397
Python Completions937
TypeScript Completions98
C# Completions216
JavaScript Completions930
F# Completions8
Prolog Completions8
C Completions49
Total Stars135
% of votes with a positive feedback rating89% of 341
Total "Very Satisfied" Votes279
Total "Somewhat Satisfied" Votes47
Total "Not Satisfied" Votes15
Total Rank Assessments13
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • EvaRD Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • rowcased Avatar
  • hobovsky Avatar
  • hakr14 Avatar
  • MaGu Avatar
  • dfhwze Avatar
  • heroicfun Avatar
Ad