-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreedisGood.cpp
More file actions
75 lines (67 loc) · 1.98 KB
/
GreedisGood.cpp
File metadata and controls
75 lines (67 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<iostream>
#include <string>
#include<vector>
using namespace std;
int score(const vector<int>& dice) {
int result = 0;
vector<int>count(7);
for (int ch : dice)
{
count[ch]++;
}
if (count[1] >= 3) {
result += 1000;
count[1] -= 3;
}
result += count[1] * 100;
if (count[5] >= 3) {
result += 500;
count[5] -= 3;
}
result += count[5] * 50;
if (count[2] >= 3) result += 200;
if (count[3] >= 3) result += 300;
if (count[4] >= 3) result += 400;
if (count[6] >= 3) result += 600;
return result;
}
int main()
{
cout << score({ 3, 3, 3, 3, 3 });
return 0;
}
/*Description:
Greed is a dice game played with five six-sided dice. Your mission,
should you choose to accept it, is to score a throw according to these rules.
You will always be given an array with five six-sided dice values.
Three 1's => 1000 points
Three 6's => 600 points
Three 5's => 500 points
Three 4's => 400 points
Three 3's => 300 points
Three 2's => 200 points
One 1 => 100 points
One 5 => 50 point
A single die can only be counted once in each roll.
For example, a given "5" can only count as part of a triplet (contributing to the 500 points) or as a single 50 points,
but not both in the same roll.
Example scoring
Throw Score
--------- ------------------
5 1 3 4 1 250: 50 (for the 5) + 2 * 100 (for the 1s)
1 1 1 3 1 1100: 1000 (for three 1s) + 100 (for the other 1)
2 4 4 5 4 450: 400 (for three 4s) + 50 (for the 5)
In some languages, it is possible to mutate the input to the function.
This is something that you should never do. If you mutate the input,
you will not be able to pass all the tests.
Algorithms*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU