# Challenge

Given a the ID for a PPCG user who has existed for at least a month, output the average amount of reputation they gain per month. You can do this by dividing their reputation by the time since their account was created (which you can find on the profile). This should be returned floored; that is, truncate all of the decimals. (We don't care about the small stuff).

# Input

A single integer, which is the user's ID

# Output

A single integer, representing the floored rep change per month.

# Test Cases

input -> output
42649 -> 127 (me)
12012 -> 3475 (Dennis)
8478  -> 3015 (Martin Ender)

• Can you define what a month is considered to be - a calendar month, a lunar month or 30 days? Or is it at our discretion? – Shaggy May 5 '17 at 7:27
• @Shaggy When you go to a user profile, under the profile tab, it says "User for <x time>". Go by that. – HyperNeutrino May 10 '17 at 17:46
• @HyperNeutrino so the formula is (rep/daysSinceAccountCreate)*30? You need to give us a constant for what a month is. – Sirens May 11 '17 at 17:39
• @Sirens Go here and Ctrl-F for 1 year, 9 months. That's what I mean. – HyperNeutrino May 11 '17 at 18:10
• Should a check that the user has existed for at least a month be included? – DimP May 18 '17 at 13:02

# JS, ES6 243235168166165 164 bytes

i=>fetch(//api.stackexchange.com/users/${i}?site=codegolf).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3))))  Based on the Python answer. Run this in the console: (i=>fetch(//api.stackexchange.com/users/${i}?site=codegolf).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3)))))(+prompt("Enter a userId"))


-4 thanks to @insert_name_here

z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert((/([\d,]+) <span class="label-uppercase">repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0))))


Improvements welcome! Just fetches the profile page and parses it with regular expressions!

Won't work as a stack snippet, but you can paste this in your console:

(z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert(Math.floor(/([\d,]+) <span class="label-uppercase">repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0)))))(+prompt("Enter a userId"))

• Okay :) You have a much higher rep change than me D: I think about double – HyperNeutrino May 18 '17 at 13:25
• You could save two bytes by using new Date instead of Date.now(). You could also save one more by using 1e3 instead of 1000 and another by using 2592e3 instead of 2592000. – insert_name_here May 18 '17 at 14:22

## Python 3 2, 206219201 193 bytes

import requests,time
a=requests.get('http://api.stackexchange.com/users/'+str(input())+'?site=codegolf').json()['items'][0]
print a['reputation']/((int(time.time())-a['creation_date'])/2592000)


I am estimating the months as the OP suggested, but actually print(int(b/((d-c)/2592000))) is a more accurate solution than print(int(b/int((d-c)/2592000))) and also saves a few bytes.

• get is not defined – HyperNeutrino May 18 '17 at 13:17
• @HyperNeutrino try it again now, should work (Python 2). Obviously needs requests. – DimP May 18 '17 at 13:41