7 kyu

Row Weights

1,381 of 24,814MrZizoScream

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 Trained34227
Total Skips3562
Total Code Submissions51837
Total Times Completed24814
C++ Completions1381
Ruby Completions513
JavaScript Completions9179
Python Completions6785
Crystal Completions16
C Completions586
Java Completions3048
C# Completions1018
Haskell Completions166
Rust Completions625
Dart Completions790
VB Completions132
PHP Completions607
Julia Completions39
NASM Completions19
CoffeeScript Completions14
TypeScript Completions479
Reason Completions9
Elixir Completions99
CFML Completions17
Clojure Completions76
Prolog Completions31
COBOL Completions10
Total Stars269
% of votes with a positive feedback rating94% of 2718
Total "Very Satisfied" Votes2399
Total "Somewhat Satisfied" Votes299
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