Find a User's SE Reputation

10

1

Challenge

Given a SE user's ID, output the sum of their reputation from across all of the Stack Exchange networks​ the user has signed up to.

Rules

If a user has 101 or less reputation on a site, count it as zero in the sum.

You should not count Area 51 rep or hidden communities!!

URL shorteners are disallowed.

Examples

Subject to change

User 3244989 (Beta Decay)

14141

User 918086 (Dennis)

204892

User 11683 (Jon Skeet)

1029180

Winning

The shortest code in bytes wins.

Beta Decay

Posted 2017-04-22T09:54:31.307

Reputation: 21 478

Answers

1

curl, grep and awk, 106 bytes

curl http://api.stackexchange.com/users/$1/associated|grep -o n\"[^,]*|awk -F: '$2>101{s+=$2}END{print s}'

It's dirty but seems to work well. I don't use awk often so I wouldn't be surprised if there was a way to golf the grep away with it.

Aaron

Posted 2017-04-22T09:54:31.307

Reputation: 3 689

3

Python 2 (with Requests), 149 Bytes

from requests import*
lambda i,r="reputation":sum(u[r]for u in get("http://api.stackexchange.com/users/"+i+"/associated").json()["items"]if u[r]>101)

I requested the API, converted the API to JSON, then summed the reputation via a generator expression. The generator does remove accounts with less than 101 reputation.

Credit for improving the code: Jonathan Allan.

Neil

Posted 2017-04-22T09:54:31.307

Reputation: 2 417

1

R with httr, 146 Bytes

library(httr)
a=sapply(content(GET(paste0("http://api.stackexchange.com/users/",readline(),"/associated")))$items,'[[','reputation')
sum(a[a>101])

Neil

Posted 2017-04-22T09:54:31.307

Reputation: 2 417

0

JavaScript (ES6), 148 143 142 141 bytes

u=>fetch(`//api.stackexchange.com/users/${u}/associated`).then(j=>j.json(s=0)).then(i=>(i.items.map(r=>s+=(r=r.reputation)>101&&r),alert(s)))

Try it

f=

u=>fetch(`//api.stackexchange.com/users/${u}/associated`).then(j=>j.json(s=0)).then(i=>(i.items.map(r=>s+=(r=r.reputation)>101&&r),alert(s)))

i.addEventListener("submit",e=>{e.preventDefault();(v=+i.firstChild.value)&&f(v)})
<form id=i><input type=number><button>Calc.</button></form>

Shaggy

Posted 2017-04-22T09:54:31.307

Reputation: 24 623

Does this ignore Area 51? – Beta Decay – 2017-04-22T19:06:20.557

@BetaDecay, I think so. I'm editing a caveat into my answer now to explain. – Shaggy – 2017-04-22T19:14:36.840

Oh right, I didn't think it'd be so simple to filter out – Beta Decay – 2017-04-22T19:23:29.797

@BetaDecay, is that confirmation that that endpoint doesn't include A51 sites? – Shaggy – 2017-04-22T19:28:02.573

What do you mean by endpoint? :/ – Beta Decay – 2017-04-22T19:31:10.133

@BetaDecay, the API endpoint I'm using to retrieve a user's data. e.g., does http://api.stackexchange.com/users/918086/associated include A51 sites. From Neil's comnent on his answer, it looks like it doesn't.

– Shaggy – 2017-04-22T19:37:33.050

Let us continue this discussion in chat.

– Beta Decay – 2017-04-22T19:40:33.597

0

Ruby 2.4, 136 + 20 = 156 bytes

Requires the -rjson -rnet/http -n flags. Input is from STDIN (no trailing newline). Ruby 2.4 is needed for sum.

p JSON.parse(Net::HTTP.get URI"http://api.stackexchange.com/users/#$_/associated")["items"].map{|i|i["reputation"]}.select{|i|i>101}.sum

Value Ink

Posted 2017-04-22T09:54:31.307

Reputation: 10 608