6 kyu

World Bits War

520 of 1,378GiacomoSorbi

Description:

Variation of this nice kata, the war has expanded and become dirtier and meaner; both even and odd numbers will fight with their pointy 1s. And negative integers are coming into play as well, with, ça va sans dire, a negative contribution (think of them as spies or saboteurs).

A number's strength is determined by the number of set bits (1s) in its binary representation. Negative integers work against their own side so their strength is negative. For example -5 = -101 has strength -2 and +5 = +101 has strength +2.

The side with the largest cumulated strength wins.

Again, three possible outcomes: odds win, evens win and tie.

Examples:

[1,5,12]    => "odds win"  //   1 + 101 vs 1100,         3 vs 2
[7,-3,20]   => "evens win" // 111 - 11  vs 10100,    3 - 2 vs 2
[7,-3,-2,6] => "tie"       // 111 - 11  vs -1 + 110,  3 - 2 vs -1 + 2
Bits
Binary
Arrays
Fundamentals

Similar Kata:

Stats:

CreatedJan 23, 2017
PublishedJan 24, 2017
Warriors Trained2831
Total Skips425
Total Code Submissions4858
Total Times Completed1378
JavaScript Completions414
Python Completions520
Ruby Completions59
Crystal Completions10
PHP Completions81
Java Completions216
C# Completions113
C Completions54
Total Stars75
% of votes with a positive feedback rating96% of 340
Total "Very Satisfied" Votes313
Total "Somewhat Satisfied" Votes26
Total "Not Satisfied" Votes1
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • GiacomoSorbi Avatar
  • CodeVortex Avatar
  • smolen Avatar
  • St3f4n Avatar
  • EatYourBeetS Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
Ad