Draft

Tug-o'-War

505 of 1,680edm2410

Description:

In this Kata we will play a classic game of Tug-o'-War!

Two teams of 5 members will face off, the strongest of which will prevail. Each team member will be assigned a strength rating (1-9), with the most powerful members having a rating of 9. Your goal is to determine, based on the cumulative strength of the members of each team, which team will win the war.

The teams will be represented by an array of arrays:

[[5,0,3,2,1], [1,6,8,2,9]]  // 11 < 26 ; "Team 2 wins!"
new int[][] { new int[] {5,0,3,2,1}, new int[] {1,6,8,2,9} } // 11 < 26 ; "Team 2 wins!"
new int[][]{new int[]{5, 0, 3, 2, 1}, new int[]{1, 6, 8, 2, 9}} // 11 < 26 ; "Team 2 wins!"
[[5,0,3,2,1], [1,6,8,2,9]]  # 11 < 26 ; "Team 2 wins!"
[[5,0,3,2,1], [1,6,8,2,9]]  # 11 < 26 ; "Team 2 wins!"

Your task is to return a string with which team won or if it was a tie.

  • If team one is stronger, return the string "Team 1 wins!"
  • If team two is stronger, return the string "Team 2 wins!"

If the two teams are of equal strength, the team with the strongest Anchor (the member furthest from the center of the rope (first member for Team 1, last member for Team 2)) will win. In the above example, the member with strength 5 is team one's Anchor and strength 9 is team two's Anchor.

  • If the teams and the Anchors are both of equal strength, return the string "It's a tie!"

The Anchors are members in each end of the rope:

anchors

more examples:

[[1,2,3,4,5], [1,2,3,4,5]] // Team 2 has stronger Anchor ; "Team 2 wins!"
[[1,2,3,4,5], [5,4,3,2,1]] // Teams & Anchors are tied; "It's a tie!"
new int[][] { new int[] {1,2,3,4,5}, new int[] {1,2,3,4,5} } // Team 2 has stronger Anchor ; "Team 2 wins!"
new int[][] { new int[] {1,2,3,4,5}, new int[] {5,4,3,2,1} } // Teams & Anchors are tied; "It's a tie!"
new int[][]{new int[]{1, 2, 3, 4, 5}, new int[]{1, 2, 3, 4, 5}} // Team 2 has stronger Anchor ; "Team 2 wins!"
new int[][]{new int[]{1, 2, 3, 4, 5}, new int[]{5, 4, 3, 2, 1}} // Teams & Anchors are tied; "It's a tie!"
[[1,2,3,4,5], [1,2,3,4,5]] # Team 2 has stronger Anchor ; "Team 2 wins!"
[[1,2,3,4,5], [5,4,3,2,1]] # Teams & Anchors are tied; "It's a tie!"
[[1,2,3,4,5], [1,2,3,4,5]] # Team 2 has stronger Anchor ; "Team 2 wins!"
[[1,2,3,4,5], [5,4,3,2,1]] # Teams & Anchors are tied; "It's a tie!"

Good luck!

Arrays
Fundamentals

More By Author:

Check out these other kata created by edm2410

Stats:

CreatedDec 4, 2014
Warriors Trained3494
Total Skips510
Total Code Submissions10234
Total Times Completed1680
JavaScript Completions790
C# Completions176
Python Completions505
Java Completions186
CoffeeScript Completions9
Ruby Completions60
Total Stars46
% of votes with a positive feedback rating92% of 522
Total "Very Satisfied" Votes450
Total "Somewhat Satisfied" Votes60
Total "Not Satisfied" Votes11
Total Rank Assessments521
Average Assessed Rank
7 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • edm2410 Avatar
  • jhoffner Avatar
  • xehpuk Avatar
  • ChristianECooper Avatar
  • TehCupcakes Avatar
  • MMMAAANNN Avatar
  • brunolm Avatar
  • nick.strohl Avatar
  • kazk Avatar
  • FArekkusu Avatar
  • ___i Avatar
  • krnets Avatar
  • WestwardLand968 Avatar
Ad