7 kyu

Simple Fun #131: Learn Charitable Game

217 of 448myjinxin2015

Description:

Task

You have some people who are betting money, and they all start with the same amount of money (this number>0).

Find out if the given end-state of amounts is possible after the betting is over and money is redistributed.

Input/Output

  • [input] integer array arr

the proposed end-state showing final amounts for each player

  • [output] a boolean value

true if this is a possible end-state and false otherwise

Examples

  • For arr = [0, 56, 100], the output should be true.

Three players start with the same amount of money 52.

At the end of game, player 1 lose 52, player2 win 4, and player3 win 48.

  • For arr = [0, 0, 0], the output should be false.

Players should start with a positive number of of money.

  • For arr = [11], the output should be true.

One player always keep his money at the end of game.

  • For arr = [100, 100, 100, 90, 1, 0, 0], the output should be false.

These players can not start with the same amount of money.

Puzzles

Stats:

CreatedFeb 17, 2017
PublishedFeb 17, 2017
Warriors Trained833
Total Skips13
Total Code Submissions1094
Total Times Completed448
JavaScript Completions156
C# Completions78
Python Completions217
Ruby Completions46
Total Stars6
% of votes with a positive feedback rating88% of 147
Total "Very Satisfied" Votes118
Total "Somewhat Satisfied" Votes24
Total "Not Satisfied" Votes5
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • tachyonlabs Avatar
  • hobovsky Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad