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 betrue
.
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 befalse
.
Players should start with a positive number of of money.
- For
arr = [11]
, the output should betrue
.
One player always keep his money at the end of game.
- For
arr = [100, 100, 100, 90, 1, 0, 0]
, the output should befalse
.
These players can not start with the same amount of money.
Puzzles
Similar Kata:
Stats:
Created | Feb 17, 2017 |
Published | Feb 17, 2017 |
Warriors Trained | 833 |
Total Skips | 13 |
Total Code Submissions | 1094 |
Total Times Completed | 448 |
JavaScript Completions | 156 |
C# Completions | 78 |
Python Completions | 217 |
Ruby Completions | 46 |
Total Stars | 6 |
% of votes with a positive feedback rating | 88% of 147 |
Total "Very Satisfied" Votes | 118 |
Total "Somewhat Satisfied" Votes | 24 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |