17
\$\begingroup\$

Well the community is just a bot. But what if it would have been a person?

Your task is to find what community's reputation might have been if it would have been given reputation for the edits it makes.(simply 2*edits)

This should work for any site, but we would consider PP&CG for this question.

Use any language, even data.stackexchange would work.

As it is code golf, smallest code wins as much reputation I gain+15(via bounty, I will leave 101 for myself :P ).

EDIT: consider all kind of edits that increase reputation.

\$\endgroup\$
10
  • 3
    \$\begingroup\$ What if you have downvotes? Will you give us negative reputation as well? \$\endgroup\$
    – user12205
    Apr 3, 2014 at 10:43
  • 2
    \$\begingroup\$ Should we count only suggested edits or normal edits (which do NOT increase rep) as well? What about tag wiki edits? \$\endgroup\$
    – Doorknob
    Apr 3, 2014 at 12:11
  • \$\begingroup\$ Why'd you link to history beta? \$\endgroup\$
    – TheDoctor
    Apr 3, 2014 at 12:16
  • \$\begingroup\$ @thedoctor my mistake.Please change it to PPCG link.I don't have access to my computer currently. \$\endgroup\$ Apr 3, 2014 at 12:25
  • 1
    \$\begingroup\$ Do we have to consider the cutoff? There is a maximum of reputation that can be gained in this manner. My guess is that on many sites, community would have reached this maximum. \$\endgroup\$ Apr 3, 2014 at 12:45

7 Answers 7

4
+25
\$\begingroup\$

I know URL shorteners are cheaty but since everyone else is using them I probably should.

Bash, with bc and URL shortener: 67 62 60 58 54

bc<<<`wget x.co/4Ccg3 -qO-|grep -oP "(?<='>)[0-9]+"`*2

Downloads the relevant page to STDOUT, then searches for '> followed by a sequence of digits - it misuses the fact that in the page's source code, single quotes are only rarely used; in fact the sequence '> occurs twice, and only once followed by a number, which is the number of edits. Using the Perl-style lookbehind, the '> isn't actually included in the match.

The -o option makes grep output only the matched string rather than the entire line containing it (there is a h1 on the same line and I don't want that).

The resulting number of edits is concatenated with *2 and sent to bc.

@11684 pointed out that you start out with 1 reputation, but the asker clearly forgot that so it's not mentioned in the question (it would break existing answers if it was). If you want to add that in just put in +1 at the end of the code, adding 2 chars.

SHELF, 36 - doesn't count as the language was created after the question

, `W x.co/4Ccg3|t "(?<='>)[0-9]+"`*2

SHELF is a golfed version of Bash, like PYG is for Python.

\$\endgroup\$
3
  • \$\begingroup\$ I'm going to steal your shortened link, as x.co is shorter than goo.gl. :) \$\endgroup\$
    – 11684
    Apr 14, 2014 at 15:00
  • \$\begingroup\$ @11684 i don't mind, i already gave it to Synthetica \$\endgroup\$
    – user16402
    Apr 14, 2014 at 15:04
  • \$\begingroup\$ URL shortening, clever ;) \$\endgroup\$
    – user18660
    Apr 14, 2014 at 18:12
2
\$\begingroup\$

Python (191 181 170 126 117)

@Henrik: Good idea to use an url shortener. Don't mind if I just borrow yours, do you? Just to kick it off, this will probably get beaten very, very fast ;)

i=__import__("urllib2").urlopen("http://x.co/4Ccg3").read();j=i[i.index("<span class='count")+20:];print 2*int(j[:2])

Searches for the <span class='count'> that contains the amount of reputation the bot has.

\$\endgroup\$
4
  • \$\begingroup\$ You should be able to remove community from the url. \$\endgroup\$
    – Geobits
    Apr 3, 2014 at 13:51
  • 1
    \$\begingroup\$ Er, this doesn't work. Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '' \$\endgroup\$
    – user80551
    Apr 3, 2014 at 15:15
  • \$\begingroup\$ @ace Something buggered up somewhere, not sure why. Anyways: it does work now. \$\endgroup\$ Apr 3, 2014 at 16:36
  • \$\begingroup\$ more shorterer: x.co/4Ccg3 \$\endgroup\$
    – user16402
    Apr 3, 2014 at 17:03
2
\$\begingroup\$

JavaScript (EcmaScript 6 + jQuery) - 80 Characters

$.get('/users/-1/?tab=activity&sort=revisions',r=>alert($('.count',r).text()*2))

Run it in the JavaScript console on any StackExchange page (although ECMAScript 6 arrow functions are only supported on FireFox at the moment so it will have do be done in that browser until the others catch up) and will get Community's reputation on that domain. So running it on http://codegolf.stackexchange.com will get the Code Golf Community's reputation (currently 118) and running it on http://academia.stackexchange.com/ would get the reputation from that site (currently 162).

Which hopefully answers the

This should work for any site

bit of the question.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ I feel like using jQuery should add 83532 to the end score \$\endgroup\$
    – JoshWillik
    Apr 14, 2014 at 15:15
1
\$\begingroup\$

JavaScript (with jQuery) - 141

$.get('http://codegolf.stackexchange.com/users/-1/?tab=activity&sort=revisions',function(o){alert($('<a>').html(o).find('.count').html()*2)})

EDIT : only works if executed from any StackExchange page... or if same origin policy is disabed.

If same origin policy is disabled, can be shorten to 96 chars :

$.get('http://tinyurl.com/pfmsq8w',function(o){alert($('<a>').html(o).find('.count').html()*2)})
\$\endgroup\$
1
\$\begingroup\$

I've included the 1 reputation that you start with!

jQuery, 76

$a=$("body");$a.load("//x.co/4Ccg3 .count",function(){$a.text($a.text()*2+1)

on any page with jQuery and requested by http.

jQuery, only works on the relevant page - 23

$(".count").text()*2+1;

The page it runs on is http://goo.gl/JOqzpF.

\$\endgroup\$
1
\$\begingroup\$

StackExchange Data 78 chars

Click here to run the query

SELECT COUNT(*)*2FROM PostHistory WHERE UserId=-1AND PostHistoryTypeId IN(4,5)
\$\endgroup\$
0
\$\begingroup\$

PowerShell (143)

My first ever PowerShell script! Counts the number of revisions and times it by two (very inspired by @Synthetica's Python answer).

$s=(New-Object Net.WebClient).DownloadString("http://tinyurl.com/pfmsq8w");(0+($s.Substring($s.IndexOf("s='cou")+10,8) -replace "[^\d]",""))*2
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.