7 kyu

Row Weights

1,425 of 25,668MrZizoScream

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 Trained35284
Total Skips3653
Total Code Submissions53488
Total Times Completed25668
C++ Completions1425
Ruby Completions518
JavaScript Completions9449
Python Completions7116
Crystal Completions16
C Completions607
Java Completions3118
C# Completions1044
Haskell Completions175
Rust Completions644
Dart Completions814
VB Completions138
PHP Completions627
Julia Completions39
NASM Completions21
CoffeeScript Completions14
TypeScript Completions508
Reason Completions9
Elixir Completions103
CFML Completions18
Clojure Completions78
Prolog Completions31
COBOL Completions10
Total Stars275
% of votes with a positive feedback rating94% of 2761
Total "Very Satisfied" Votes2436
Total "Somewhat Satisfied" Votes304
Total "Not Satisfied" Votes21
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