Exploring 10-Rep Questions

5

1

Related

Introduction

As it happens, someone put forward the idea that, since PPCG has graduated, up votes on questions should be worth 10 rep. As a result, I started wondering how much rep I would have if it had always been 10 rep.

Challenge

Given a PPCG user's id as input, output how much total rep the user would have if question up votes were worth +10.

Example Calculation

I, Beta Decay (user id 30525), have 6744 rep. 3488 of that was earned by posting questions (calculated by subtracting the total rep lost from downvotes from the total rep gained from upvotes).

Firstly, we subtract 3488 from 6744, giving us 3256 rep, the amount earned from posting answers.

Next, we find out how much I would have earned from 10 rep questions by simply multiplying 3488 by 2, giving us 6976.

Finally, we add 3256 and 6976 together to get a final answer of 10232 rep.

A simplified method is to take the total, 6744 and add the rep from questions, 3488, giving is 10232 rep.

For continuity, you must use the method described above

Examples

Note that these examples are subject to change and are unlikely to stay current.

Helka Homba (UID 26997)

71398

Martin Ender (UID 8478)

121077

Downgoat (UID 40695)

21894

Rules

Internet access is allowed. Similarly, access to the Stack Exchange API is allowed. However, URL shorteners are disallowed.

T-SQL entrants using the Stack Exchange Data Explorer are allowed.

You also do not have to take into account the daily rep cap of 200.

Winning

Shortest code in bytes wins.

Beta Decay

Posted 2016-08-23T11:02:07.633

Reputation: 21 478

4If we don't take down votes into account where does 3488 come from, as it's not a multiple of 5? – Neil – 2016-08-23T11:09:39.897

@Neil Hm, well I've changed the rules now to accountt for this – Beta Decay – 2016-08-23T11:22:09.367

Answers

1

Python, 336 Bytes

Anonymous lambda function, takes a string.

Should work, but couldn't test it, because I drained my api quota.

(Warning! Will drain your api quota!)

import requests,re
lambda x,u="http://api.stackexchange.com/2.2/users/%s%s?site=codegolf&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(99)])

a bit quota-friendlier:

import requests,re
f=lambda x,u="https://api.stackexchange.com/2.2/users/%s%s?site=codegolf&pagesize=100&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(30)])

KarlKastor

Posted 2016-08-23T11:02:07.633

Reputation: 2 352