# Challenge

Given a user's ID, determine how many times they have hit the repcap.

# Specs

On a given day, let's a user has hit the repcap if they had reputation that wasn't gained due to the repcap. Essentially, on any given day, if the user's net reputation change as calculated without any cap was different from their actual observed reputation change, then they hit the repcap.

# Input/Output

Input will be a single integer, the user's ID.
Output will be a single integer, indicating the number of days for which they had reputation that was "lost".
I/O can be in any reasonable format.

# Test Cases

Feel free to add your own ID and stats here. The brackets indicate which user it is, but that isn't part of the output. Don't include it.

input -> output (username)
42649 -> 0 (HyperNeutrino)
41723 -> 7 (Fatalize)
46271 -> 0 (Riker) (This user has obtained 200 rep twice, but never over)

• For the record, your criterion is different from that of the mortarboard badge. For that you just need 200 rep, even if you haven't got the rep cap at that point (the rules are a bit more complicated because not all rep changes count towards the badge). – Martin Ender May 1 '17 at 14:30
• @MartinEnder Yes. I decided to simplify it so people didn't have to count badge progress. Essentially, it counts if and only if the user didn't gain rep they otherwise would have. – HyperNeutrino May 1 '17 at 14:31
• This question is of interest to me because I happened to hit the rep cap a couple of times last month and I've already hit it again today. +1 – Neil May 1 '17 at 16:01
• – Stewie Griffin May 1 '17 at 16:56
• @StewieGriffin I was inspired to write this challenge because of your challenge, in fact. :) :P – HyperNeutrino May 1 '17 at 20:04

# JS ES6, 360 bytes

f=(i,p=1,d=[])=>fetch(https://api.stackexchange.com/2.2/users/${i}/reputation?site=codegolf&pagesize=100&page=${p}).then(x=>x.json()).then(j=>(q=d.concat(j.items),j.has_more?f(i,p+1,q):(r=[],q.map(s=>(r[d=new Date(s.on_date*1000),i=d.getDate()+d.getMonth()*32+d.getYear()*365]?r[i]+=s.reputation_change:r[i]=s.reputation_change)),r.filter(x=>x>200).length)))


Call it like f(user id). Returns a promise that resolves with the number of days that rep was lost.

Ungolfed:

f=(i,p=1,d=[])=>fetch(https://api.stackexchange.com/2.2/users/${i}/reputation?site=codegolf&pagesize=100&page=${p}&key=kAc8QIHB*IqJDUFcjEF1KA(().then(x=>x.json()).then(j=>{
return (q=d.concat(j.items),
j.has_more?
f(i,p+1,q)

:(r=[],
q.map(s=>(r[d=new Date(s.on_date*1000),
i=d.getDate()+d.getMonth()*32+d.getYear()*365]?
r[i]+=s.reputation_change

:r[i]=s.reputation_change)),
r.filter(x=>x>200).length
)
)
});