3
\$\begingroup\$

This is a pretty cool CodeGolf challenge in the sense that you're only going to have a limited amount of time to do it. You need to build a program that "mines" StackOverflow unicoins. In order to do this, you need to perform just two HTTP requests. I'm not going to say how, to add to the fun.

The first person to do this gets a -10 on their score. Good luck! Also, if your doing this in JavaScript or similar, you don't need to account for the target browser's XSS, etc. prevention.

\$\endgroup\$
5
  • 7
    \$\begingroup\$ Where by "only going to have one day to do it" you mean "it's too late to test if you live anywhere in the Eastern hemisphere"? \$\endgroup\$ Commented Apr 1, 2014 at 22:26
  • \$\begingroup\$ @PeterTaylor Yup :) EDIT: lol I fixed it \$\endgroup\$
    – Taconut
    Commented Apr 1, 2014 at 22:30
  • 2
    \$\begingroup\$ -1 for unfairness - I already have no access to the Unicoins at the time you posted this challenge. \$\endgroup\$
    – user12205
    Commented Apr 2, 2014 at 5:59
  • 5
    \$\begingroup\$ This question appears to be off-topic because results cannot be reliably tested. \$\endgroup\$
    – Geobits
    Commented Apr 2, 2014 at 12:55
  • \$\begingroup\$ Unicoins are gone, bro \$\endgroup\$
    – TheDoctor
    Commented Apr 2, 2014 at 13:37

1 Answer 1

6
\$\begingroup\$

Javascript, 104 (114 chars - 10 bonus)

All due credit here. Simply posting this to get the "first answer" -10 bonus ;-).

p='$.post("/unicoin/'
setInterval(p+'rock",function(o){'+p+'mine?rock="+o.rock,StackExchange.options.user)})',2e4)

setInterval accepts both functions and strings of code. After susbtituting the variable p, the following gets executed every 20 seconds:

$.post("/unicoin/rock", function(o) {
    $.post("/unicoin/mine?rock=" + o.rock, StackExchange.options.user)
} 

Edits are welcome. I don't know well enough to really competitively golf this.

\$\endgroup\$
4
  • \$\begingroup\$ Save the url in a var ( the /unicoin/ part ) and you shave off some bytes. Also delete all the un-needed whitespace. AND you are using jQuery and you make no references about it. AND reduce the var names. And you should mark it as a community wiki \$\endgroup\$ Commented Apr 1, 2014 at 22:29
  • \$\begingroup\$ You can also reduce it by one character by changing the 15 to a one-digit number \$\endgroup\$
    – Jwosty
    Commented Apr 1, 2014 at 22:59
  • \$\begingroup\$ It has to be 15 or higher. If its not, it'll give you an interrupted error. What about rounding up to 2e2? \$\endgroup\$
    – Taconut
    Commented Apr 1, 2014 at 23:29
  • \$\begingroup\$ Passing a string of code to setInterval manages to save a bunch of characters. Also, $.post allows to specify a callback function (no need for .done()) and we can include the entire object StackExchange.options.user in the POST request instead of extracting the fkey value from it (which is the single one we actually need). \$\endgroup\$
    – Dennis
    Commented Apr 2, 2014 at 4:46

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