7 kyu

Row Weights

1,389 of 25,058MrZizoScream

Description:

Several people are standing in a row divided into two teams. The first person goes into team 1, the second goes into team 2, the third goes into team 1, and so on.

Task

Given an array of positive integers (the weights of the people), return a new array / tuple of two integers (depending on your language), whereby the first one is the total weight of team 1, and the second one is the total weight of team 2. Note that the array will never be empty.

Examples

  • [13, 27, 49] returns [62, 27] or (62, 27) (depending on your language) because the total weight of team 1 is 13+49=62 13 + 49 = 62 and the total weight of team 2 is 27 27 .
  • [50, 60, 70, 80] returns [120, 140] or (120, 140) (depending on your language) because the total weight of team 1 is 50+70=120 50 + 70 = 120 and the total weight of team 2 is 60+80=140 60 + 80 = 140 .
  • [80] returns [80, 0] or (80, 0) (depending on your language) because the total weight of team 1 is 80 80 and the total weight of team 2 is 0 0 .

Playing with Numbers Series

Playing With Lists/Arrays Series

For More Enjoyable Katas

Fundamentals
Arrays

Stats:

CreatedMar 29, 2018
PublishedMar 29, 2018
Warriors Trained34532
Total Skips3588
Total Code Submissions52302
Total Times Completed25058
C++ Completions1389
Ruby Completions514
JavaScript Completions9257
Python Completions6899
Crystal Completions16
C Completions592
Java Completions3063
C# Completions1026
Haskell Completions167
Rust Completions628
Dart Completions795
VB Completions133
PHP Completions611
Julia Completions39
NASM Completions19
CoffeeScript Completions14
TypeScript Completions483
Reason Completions9
Elixir Completions99
CFML Completions17
Clojure Completions78
Prolog Completions31
COBOL Completions10
Total Stars273
% of votes with a positive feedback rating94% of 2735
Total "Very Satisfied" Votes2413
Total "Somewhat Satisfied" Votes302
Total "Not Satisfied" Votes20
Total Rank Assessments18
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • MrZizoScream Avatar
  • GiacomoSorbi Avatar
  • donaldsebleung Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • B1ts Avatar
  • Jay-9 Avatar
  • Voile Avatar
  • realfg Avatar
  • rsa Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • bdw429s Avatar
  • monadius Avatar
  • cliffstamp Avatar
  • uniapi Avatar
  • stellartux Avatar
  • user8436785 Avatar
  • user7527943 Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
Ad