A couple months ago, we had a discussion on meta about increasing the reputation awarded for upvotes on questions. Here's the basics of our current reputation system for votes:1
- A question upvote
U
is worth 5 reputation. - An answer upvote
u
is worth 10 reputation. - A question or answer downvote
d
is worth -2 reputation.
There have been many different suggestions for a new system, but the current most popular is identical to the above, but with question upvotes scaled to +10 rep. This challenge is about calculating how much more rep you would earn if this system were put into place.
Let's look at an example. If the voting activity was UUUUuuuuUUUUUduuudUU
, then you'd earn 121 under the current system:
U x 4 x 5 = 20 = 20
u x 4 x 10 = 40 = 60
U x 5 x 5 = 25 = 85
d x 1 x -2 = -2 = 83
u x 3 x 10 = 30 = 113
d x 1 x -2 = -2 = 111
U x 2 x 5 = 10 = 121
Total: 121
But the same activity would earn 176 under the new system:
U x 4 x 10 = 40 = 40
u x 4 x 10 = 40 = 80
U x 5 x 10 = 50 = 130
d x 1 x -2 = -2 = 128
u x 3 x 10 = 30 = 158
d x 1 x -2 = -2 = 156
U x 2 x 10 = 20 = 176
Total: 176
You would gain 55 rep from this scenario.
So far, calculating the changed rep isn't that hard; just count the number of U
s and multiply by 5. Fortunately, the rep system isn't that simple: there is also a rep cap, which is the most reputation you can earn from votes in one UTC day. This is set to 200 on all sites.
Also, the rep cap applies in real time: if you have already earned 196 rep and you receive an answer upvote, you will now have 200 rep. If you get a downvote right after that, the 2 rep will be subtracted from 200, so you will have 198 rep.
With the voting activity UUUuuuuUUUUuuuuUUUUUUUd
, you would earn 148 rep under the current system:
U x 3 x 5 = 15 = 15
u x 4 x 10 = 40 = 55
U x 4 x 5 = 20 = 75
u x 4 x 10 = 40 = 115
U x 7 x 5 = 35 = 150
d x 1 x -2 = -2 = 148
Total: 148
But you would earn 198 under the new system:
U x 3 x 10 = 30 = 30
u x 4 x 10 = 40 = 70
U x 4 x 10 = 40 = 110
u x 4 x 10 = 40 = 150
U x 7 x 10 = 70 = 200 (rep capped)
d x 1 x -2 = -2 = 198
Total: 198
Thus, the increase is 50 rep.
Challenge
Your challenge is to write a program or function that takes in a multi-line string and outputs the total rep that would be gained with the above algorithm. Each line counts as 1 UTC day, so the rep cap only applies once per line.
Test cases
(One or more lines of input, followed by the output integer.)
UUUuudd
15
UUUuUUUUuUuuUUUUudUUUUuU
57
UUUuUUUUuUuuUUUUudUUUUuU
UUUuudd
72
uuuuuuu
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
uuuuuuuuuuuuuuuuuuuu
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
0
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
5
(empty string)
0
UUUuuuuuUUUuuUUUUUUuuuUUUuuUUUUuuuuUUUdddddddUU
4
UUUuuuuuUUUuuUUUUUUuuuUUUuuUUUUuuuuUUUdddddddUU
UuuUUUudUU
UUUUUUUUUuuuuuuUUUUUUuuUUUUUUuuuuuUUUUUUUUuUUUuuuuUUUUuuuUUUuuuuuuUUUUUUUUuuUUUuuUU
UUu
U
d
UU
UUUUUUUUUUUU
119
This is code golf, so shortest code in bytes wins.
Related challenges: Calculate the bounded cumulative sum of a vector, Calculate your stack exchange reputation
1 This is a highly simplified version of the system. You also lose 1 rep for downvoting an answer, and there exist unupvotes, which are weird and follow rules of their own; and undownvotes, which don't even have rules to follow.