I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them.

Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to the one who has more reputation at the moment the program is ran, between Dennis ♦ and Martin Ender ♦. The tricky part is that you must output the exact string "tie" in case the reputation is identical (not likely), and the two different non-whitespace ASCII strings mentioned above should be different than "tie" *.

No input can be taken, such as usernames or user ids. As usual, URL shorteners are forbidden, and so are the common loopholes.


Let the chosen string for Dennis be "D" and the chosen one for Martin Ender be "M" (should be specified)

If Dennis' rep > Martin Ender's rep => D
If it's the other way around => M
If it's a tie => tie 

IMPORTANT! Voting on posts by Dennis & Martin for the sole purpose of affecting a tie in order to test the solutions below constitutes targeted voting which is forbidden across the Stack Exchange network. If you want to test that a solution properly outputs tie then change the IDs in it to those of 2 users you know to be tied. See this Meta post for more details.

*I think no one would have used that, anyway

  • 33
    \$\begingroup\$ "... the two best code-golfers in the world ..." [citation-needed] \$\endgroup\$ Commented May 10, 2017 at 12:48
  • 9
    \$\begingroup\$ Can we assume that they will always be #1 and #2 in this community? \$\endgroup\$
    – ovs
    Commented May 10, 2017 at 14:24
  • 7
    \$\begingroup\$ A friendly reminder: targeted voting is forbidden on the entire Stack Exchange network. Voting on Martin's and my posts just to test submissions to this challenge is not allowed. \$\endgroup\$
    – Dennis
    Commented May 11, 2017 at 17:12
  • 2
    \$\begingroup\$ @Shaggy It's great that you have added that note. Hopefully, the users involved will stop doing that \$\endgroup\$
    – Mr. Xcoder
    Commented May 12, 2017 at 11:24
  • 1
    \$\begingroup\$ To @MartinEnder at the top, citations are unneeded for facts that are common knowledge. \$\endgroup\$
    – Gryphon
    Commented Aug 2, 2017 at 0:10

10 Answers 10


05AB1E, 65 64 bytes


•в=6{•5ôvy’ƒËŠˆ.‚‹º.ŒŒ/†š/ÿ’.w’„Ö="ˆ"’¡1èт£þ}})ZQā*O<“D M·‡“#è

Uses the 05AB1E encoding.


•в=6{• converts the number в=6{ from base 255 to base 10, resulting in 1201208478. The first half being the ID of Dennis (12012) and the second half being the ID of Martin (8478). Split into pieces of 5 using to get the following array:

['12012', '08478']

Luckily, we can leave the leading zero from Martin's ID, since this will still work (check the link before clicking to see the leading zero).

We now loop through this array using vy and construct the following string from this 05AB1E code:

’ƒËŠˆ.‚‹º.ŒŒ/†š/ÿ’  -->  codegolf.stackexchange.com/users/ÿ

Whereas ÿ is the current element of the iterator (using string interpolation) Try it online!

After constructing the link, .w reads all data from the link, resulting into a huge amount of text. To scrape the reputation from this, we need to split on the string title="reputation". Or in a more compressed version: ’„Ö="ˆ"’. Split on this piece of string (with ¡) and get the second element (with ) and keep the first 100 characters (with т£).

Now, our scraped text looks a bit like this:

        139,883 <span class="label-uppercase">reputation</span>
<div class="ba

This part is easy, we just remove anything but digits to remain the reputation number, for which we have a builtin (þ). We end the loop and wrap everything into an array }}).

Finally, we can go on to processing the reputation numbers:

ZQā*O<“D M·‡“#è   -   On stack: an array in the format [Dennis rep, Martin rep]

Z                 # Get the maximum of the array
 Q                # Check for equality with the array
  ā*              # Multiply by it's index (1-indexed)
    O<            # Sum and decrement by 1
      “D M·‡“#    # Push the array ['D', 'M', 'tie']
              è   # Get the element on the index of the sum

Which results in either D, M or tie.

  • 2
    \$\begingroup\$ I didn't know that 05AB1E can access internet APIs, this answer kind surprises me => +1 \$\endgroup\$
    – Mr. Xcoder
    Commented May 10, 2017 at 18:24
  • \$\begingroup\$ I always like how you and others come up with ways to get a certain number. :) +1 Btw, is the part "second element (with 1è) and keep the first **100 characters** (with т£." supposed to be completely in code-blocks, or should it be "second element (with ) and keep the first 100 characters (with т£)." instead? I guess a typo, but if it's supposed to be like this I'm confused.. \$\endgroup\$ Commented May 10, 2017 at 20:57
  • \$\begingroup\$ @KevinCruijssen Huh, I have no idea how that happened, but it's fixed now. Thanks for the heads up! :) \$\endgroup\$
    – Adnan
    Commented May 10, 2017 at 21:00
  • \$\begingroup\$ it seems incorrect (I don't know how to correct this kind of code, sorry), Dennis: 140,033; Martin: 140,003, but I tried your code here tio.run/nexus/05ab1e#@/…, it yield tie. Shouldn't it ouput D instead? \$\endgroup\$
    – Eddie
    Commented May 11, 2017 at 8:39
  • \$\begingroup\$ @Eddie .w requires web access, which is restricted on TIO (it runs 05AB1E in safe mode). In the offline interpreter, it should work. \$\endgroup\$
    – Adnan
    Commented May 11, 2017 at 8:44

PowerShell v3+, 147 123 119 103 101 96 Bytes

$a,$b=irm api.stackexchange.com/users/12012`;8478?site=codegolf|% I*|% r*n;$a-$b|% T*g "D;M;Tie"

Saved 24 bytes using true/false output instead of the names.

Saved another 4 by restructuring the final checks.

saved 16 by getting only the reputations of the two users from the request, saves having to use the |% r*n more than once, also means we can get rid of like a million brackets, and two useless variables.

-2 thanks to TessellatingHeckler - using an escape char instead of two doublequotes for the url, also removed the @ from the array which was un-needed (oopsie)

used a weird .ToString trick I never knew existed until now reccomended by TessellatingHeckler -5, and finally below 100.

Version which returns names:

$a,$b=irm "api.stackexchange.com/users/12012;8478?site=codegolf"|% I*
if(($c=$a|% r*n)-eq($d=$b|% r*n)){"tie"}else{@(($a|% d*),($b|% d*))[$c-lt$d]}

this looks pretty messy due to the shortening of parameter names.

anywhere |% r*n appears we're getting the ReputatioN, and |% d* is the Display_name

uses Invoke-RestMethod (alias irm) to query the API, stores the result named Items (gotten using |% I*), into the two variables $a & $b, one for each pro golfer's, the ToString (|% T*g) trick results in one of the values D,M or Tie if the number is odd/even/zero.

  • \$\begingroup\$ I did not expect powershell to be the shortest. +1 \$\endgroup\$
    – Riker
    Commented May 10, 2017 at 15:30
  • \$\begingroup\$ @Riker Pyth would've presumably been, but it has a horrible bug. \$\endgroup\$ Commented May 10, 2017 at 15:46
  • 1
    \$\begingroup\$ Fine, you win; no way I'm going to beat this now! \$\endgroup\$
    – Shaggy
    Commented May 10, 2017 at 17:46
  • 9
    \$\begingroup\$ So your code is 103! = 9.902900716486180407546715254581773349090165822114492483005280554699... × 10^163 bytes long..? :P \$\endgroup\$ Commented May 11, 2017 at 0:07
  • 1
    \$\begingroup\$ @TessellatingHeckler check the answer for the last bit, you got it below 100! - never knew ToString worked like that with +/- numbers, will remember for future. \$\endgroup\$
    – colsw
    Commented May 11, 2017 at 14:35

Python 2, 160 bytes

from requests import*
print cmp(*[get('http://api.stackexchange.com/users/12012;8478?%ssite=codegolf&filter=!9aK21rboZ'%s).text for s in'order=asc&',''])or'tie'

Not the shortest Python answer, but the shortest one so far that doesn't make any assumptions.

Prints 1 if Martin has more rep, -1 if I do.


JavaScript (ES6), 167 156 146 144 141 132 103 bytes

Stupid fetch and its stupid, expensive Promise chaining!

Assumes, as currently allowed, that Dennis & Martin will always be the 2 top ranked users. Needs to be run from the root level of api.stackexchange.com. Returns a Promise object (as is now permitted by consensus) containing tie or the JSON object for whoever has the most rep at the time. If the JSON object isn't considered valid output then add 5 bytes for .link.

  • Saved 11 bytes thanks to Kevin suggesting I return the profile link rather than the first letter of the display_name, which also provide better future-proofing against them changing their usernames to start with the same letter!
  • 5 bytes saved adapting a tip from kamoroso94 on a another solution of mine.

Try It



If a time comes that Dennis & Martin aren't at the top and we still want to know who has the most rep between them then we'd need the following, at a cost of an additional 10 bytes.

  • 2
    \$\begingroup\$ You can change .display_name[0] to .display_name, or an even shorter alternative that is still unique for both of them: .link. ;) Or just the entire JSON, but I'm not sure if it fits in the alert-popup. \$\endgroup\$ Commented May 10, 2017 at 13:43
  • \$\begingroup\$ Thanks, @KevinCruijssen; I had to use an extract of the username as Martin's contains a space, which isn't allowed. Good shout on using link, though, I was using a filtered API query to only return the info I needed. \$\endgroup\$
    – Shaggy
    Commented May 10, 2017 at 14:00
  • \$\begingroup\$ @KevinCruijssen I've dumped whole HTML pages into alert popups when dealing with AJAX returns. It can handle it. \$\endgroup\$ Commented May 10, 2017 at 15:17
  • \$\begingroup\$ @Draco18s, alerting a JSON object, though, will just display [object Object]. \$\endgroup\$
    – Shaggy
    Commented May 10, 2017 at 15:36
  • \$\begingroup\$ @Shaggy True, true, it would. \$\endgroup\$ Commented May 10, 2017 at 15:41

Python 3, 160 157 151 bytes

from requests import*

-3 bytes thanks to @KevinCruijssen

Prints a link to the user having more reputation

Assumes they are on #1 and #2

Without making any assumptions, Python 2, 157 bytes:

from requests import*

PHP, 167 Bytes

prints -1 for Dennis , 1 for Martin Ender. tie in case of a tie


Python, 226 225 221 bytes

I feel like this is too long.

import requests as r,re
def f(i):d=re.sub('[, ]','',r.get('http://codegolf.stackexchange.com/users/'+i).text);D=d.index('"reputation">')+14;return int(d[D:d.index('<',D)])

Prints "True" if Martin has more rep than Dennis, "False" if Dennis has more rep than Martin, and "tie" if they have the same (theoretically. I can't test this :P).

https -> http for 1 byte thanks to @KevinCruijssen! re as r, r.sub -> re, re.sub for 4 bytes thanks to @ovs!

  • \$\begingroup\$ I'm not entirely sure, but is it possible to change https to http? I know PPCG is completely https now, but perhaps it auto-directs to HTTPS when you navigate to HTTP in Python, just as it does in a browser? \$\endgroup\$ Commented May 10, 2017 at 13:38
  • \$\begingroup\$ @KevinCruijssen Ah yes, I don't know what I was thinking there. Thanks! \$\endgroup\$
    – hyper-neutrino
    Commented May 10, 2017 at 13:41
  • 1
    \$\begingroup\$ You don't need re as R. Just use import requests as r,re and re.sub \$\endgroup\$
    – ovs
    Commented May 10, 2017 at 13:53
  • \$\begingroup\$ @ovs Heh, my original approach was different Thanks! \$\endgroup\$
    – hyper-neutrino
    Commented May 10, 2017 at 14:04
  • \$\begingroup\$ I think you can use the cmp function to save some bytes by replacing the last three lines with something like print['tie',0,1][cmp(f('8478'),f('12012'))] \$\endgroup\$
    – xenia
    Commented May 10, 2017 at 15:29

Bash + jq, 140 133 bytes

w3m 'api.stackexchange.com/users/12012;8478?site=codegolf&sort=name'|jq '.items|map(.reputation)|1/(index(min)-index(max))'||echo tie

Formatted and explained

First, we curl w3m the API (and use --compressed, or short --com to un-gzip):

w3m 'api.stackexchange.com/users/12012;8478?site=codegolf&sort=name'

That's some JSON. Notice the order ist stable, not based on reputation. JQ then processes the JSON, which is what it's made for.

.items                          # take the items array
| map(.reputation)              # extract only the reputations
| 1 / 
  (index(min)-index(max))       # This checks if the bigger value is first (1) or last (-1) in array

We use 1/x above to generate an division-by-zero error when min==max, so in a tie situation. The ||echo tie in bash catches that.

Note that a warning is printed on stderr by JQ in that case, but we consider only stdout the actual result of the program ;)

  • 1
    \$\begingroup\$ You can use w3m instead of curl --com to save a few bytes. Also, I think it's worth mentioning that this requires jq 1.5, as jq 1.4 didn't raise an error for division by zero. \$\endgroup\$
    – Dennis
    Commented May 12, 2017 at 19:27
  • \$\begingroup\$ True, thanks for the hint. W3m is exactly what I was looking for. \$\endgroup\$
    – opatut
    Commented May 13, 2017 at 7:06

Python 2, 228 223 204 199 bytes

I did this on a mobile hotspot so... it's not great... Assumes both of them will always be in the same hundred thousand. Doesn't assume anything now. :D

import urllib as l,re
f=lambda i:int(re.search('n">\s*([\d,]+)',l.urlopen('http://codegolf.stackexchange.com/users/%d'%i).read()).group(1).replace(',',''))

Prints True if Dennis has more reputation than Martin, False otherwise and Tie if they are... tied.


Stackexchange API Data Explorer, 184 180 bytes

Thanks to @Kevin Cruijssen for -4 bytes

DECLARE @M int,@D int;SELECT @M=reputation from users where id=8478;SELECT @D=reputation from users where id=12012;IF @D=@M PRINT('tie')ELSE BEGIN;IF @D>@M PRINT(1)ELSE PRINT(2)END

Prints 1 for Dennis and 2 for Martin

Since i only yesterday learned about the SEADE this should be very beatable.

Try it here

  • \$\begingroup\$ You can change 'D' and 'M' to 0 and 1. \$\endgroup\$ Commented Sep 19, 2017 at 9:20

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.