Herr der Golfplätze


9

Intro

In JRR Tolkiens Herr der Ringe steht dieser Satz auf dem Cover jedes Buches.

Three Rings for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone, 
Nine for Mortal Men doomed to die,
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
One Ring to rule them all, One Ring to find them,
One Ring to bring them all, and in the darkness bind them,
In the Land of Mordor where the Shadows lie

Das ist jedoch nicht so interessant. Es ist nur . Lassen Sie uns dies in eine ändern .

Was du tun musst

Verwenden Sie die Stack Exchange-API (oder codegolf.stackexchange.com/usersden Stack Exchange-Daten-Explorer) und suchen Sie die beiden Benutzer mit den höchsten Punktzahlen im , den neuesten Benutzer und den Benutzer mit der höchsten Reputation mit nur negativ bewerteten Beiträgen.

Anschließend müssen Sie diese Benutzernamen in den folgenden Text einfügen:

Three Golfs for the <highest-scored code-golf user>-king under the sky,
Seven for the <second-highest-scored code-golf user>-lord in their halls of stone,
Nine for the Mortal <newest user> doomed to die,
One for the Dark Lord <highest reuptation user with only negative scored code-golf posts>
In the land of Golfdor, where the Golfers lie
One Golf to rule them all, One Golf to find them,
One Golf to bring them all, and in the darkness bind them,
In the Land of Golfdor, where the Golfers lie

Sie müssen die vier Benutzernamen, die Sie gefunden haben, in den Text in den spitzen Klammern einfügen.

Andere Regeln

  • Dies ist also gewinnt der kürzeste Code.
  • Keine URL Shortener (einschließlich ppcg.(ga|lol))

1
Möchten Sie In the Land of Golfdor, where the Golfers liedie Ausgabe zweimal so wie in den Büchern?
Riley

Können wir davon ausgehen, dass es mindestens einen Benutzer mit nur negativ bewerteten Code-Golf-Posts gibt?
Martin Ender

1
@ Riley Oh, ich verstehe. Bearbeitung.
NoOneIsHere

1
Könnte der Dunkle Lord 0 Punkte im Code-Golf haben oder muss es eine negative Punktzahl sein?
MegaTom

1
@ MegaTom Es muss negativ sein.
NoOneIsHere

Antworten:


2

PHP, 577 Bytes

nicht getestet; Ich habe derzeit kein System zur Verfügung allow_url_fopen=On
und habe mir nicht die Zeit genommen, die Seitenquellen zu kopieren und einzufügen.

function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}$m=preg_match_all;$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="$u&filter=all"),$b);$h=$b[2];$m("#>(.+)</a.+\s1 i#",g("users?tab=NewUsers&sort=creationdate"),$c);while($a){foreach($b[1]as$i=>$n)if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)&&$d[1][0])break 2;if($a=strstr($a,"l=\"n"))$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);}$m("#<code>(.+)</code>#U",g("q/93545"),$t);echo join([1=>$h[0],3=>$h[1],5=>$c[1][0],7=>$b[2][$i];]+split("#&[lg]t;#",$t[1][2]));

Nervenzusammenbruch

// function to get page content from ppcg
function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}

$m=preg_match_all;

// A,B: highest scores: find user names
$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="users?filter=all"),$b);
$h=$b[2];   // remember the names

// C: new users: find username after "1 in one day"
$m("#>(.+)</a.+\s1 i#",g("$u&tab=NewUsers&sort=creationdate"),$c);

// D: loop through users from first query
while($a)
{
    foreach($b[1]as$i=>$n)
        // find "vote-count-post" in code-golf votes for that user
        if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)
        &&$d[1][0])             // test if highest vote is negative
            break 2;
    // none found yet?
    if($a=strstr($a,"l=\"n"))   // if there is a "next" link, get next page
        $m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);
}

$m("#<code>(.+)</code>#U",g("q/93545"),$t); // get code blocks from question page

echo join([         // 4. join and print
    1=>$h[0],           // first two results from first preg_match
    3=>$h[1],
    5=>$c[1][0],        // first result from second preg_match
    7=>$b[2][$i];       // $i-th username from (latest) reputation list
]+                  // 3. and replace indexes 1,3,5,7 with above array
split("#&[lg]t;#",  // 2. split by "<" and ">"
    $t[1][2]        // 1. output template is the 3rd code block
));
Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.