几个月前,我们在meta上进行了讨论,讨论如何提高因问题投票而获得的声誉。这是我们目前的投票信誉系统的基础:1
- 问题投票
U
值得5个声望。 - 回答投票
u
值得10个声誉。 - 问题或答案不满意
d
的人值得-2声望。
对于新系统,已经有许多不同的建议,但是当前最受欢迎的与上面的相同,但是问题投票的比例扩大到+10个代表。这项挑战是要计算出安装该系统后您将获得多少代表。
让我们来看一个例子。如果投票活动为UUUUuuuuUUUUUduuudUU
,则在当前系统下,您的收入为121:
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
但是在新系统下,相同的活动将获得176的收入:
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
您将从这种情况下获得55个声望。
到目前为止,计算更改后的代表并不困难。只需计算U
s 的数量并乘以5。幸运的是,代表制度不是那么简单:还有一个rep cap,这是您在某个UTC一天中从投票中获得的最高声誉。在所有站点上都将其设置为200。
而且,代表上限是实时适用的:如果您已经获得196个代表并且收到了答覆投票,那么您现在将有200个代表。如果此后立即收到降票,则2个代表将从200中减去,因此您将获得198个代表。
通过投票活动UUUuuuuUUUUuuuuUUUUUUUd
,在当前系统下,您将获得148个代表:
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
但是在新系统下,您将获得198:
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
因此,增加为50 rep。
挑战
您面临的挑战是编写一个包含多行字符串并输出使用上述算法可获得的总代表的程序或函数。每行算作1个UTC天,因此代表上限仅适用于每行一次。
测试用例
(一或多行输入,后跟输出整数。)
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
这是代码高尔夫,因此以字节为单位的最短代码获胜。
相关挑战:计算向量的有界累计和,计算堆栈交换信誉
1这是系统的高度简化版本。您还会因投票否决而失去1个代表,并且存在未投票的情况,这很奇怪并且遵循自己的规则;和undownvotes,甚至没有要遵循的规则。