Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Make a code that gets list of badges that nobody received yet (for example, by using this website API for badges), and output the sorted list of such badges, with new line after each.

Example output (may be smaller, depending on when you do this challenge):

Archaeologist
Caucus
Constituent
Copy Editor
Deputy
Electorate
Epic
Generalist
Hacker
Legendary
Marshal
Outspoken
Research Assistant
Sheriff
Steward
Strunk & White
Tenacious
Unsung Hero

Smallest code wins.

share|improve this question
    
nice idea, also suspect Stack Exchange Data Explorer could do it (no answers on that so far) in fact maybe the web query is doing a SQL query at heart... –  vzn Mar 25 at 17:59
add comment

4 Answers

up vote 7 down vote accepted

JavaScript with jQuery (loaded onto SE sites by default), 58

$('.badge',$('.badge-count:not(:has(*))').parent()).text()

Must be run on http://codegolf.stackexchange.com/help/badges. ;)

Strictly conforming output, 116 chars:

[].join.call($('.badge',$('.badge-count:not(:has(*))').parent()).map(function(){return $(this).text()}).sort(),'\n')

Screenshot of console output (click to enlarge):

screenshot of console output

share|improve this answer
    
Is using external libs allowed? –  Ultra Jan 4 at 14:21
2  
@Ultra jQuery is loaded onto SE sites by default. –  Doorknob Jan 4 at 14:36
add comment

Bash, 173 characters

curl "https://api.stackexchange.com/2.1/badges?page="{0..50}"&pagesize=100&order=desc&sort=type&site=codegolf"|gunzip|grep -Po '{"name".*?award_count":0.*?}'|cut -d'"' -f 4

Though you could probably shave some characters off by using url shortening.

WARNING: Note that running this script a couple of times will result in this:

{"error_name":"throttle_violation","error_message":"too many requests from this IP, more requests available in 84495 seconds","error_id":502}

Output for codegolf.SE:

code-golf
Informed
Research Assistant
Caucus
Constituent
Outspoken
Deputy
Vox Populi
Excavator
Analytical
Self-Learner
Hacker
Beta
Legendary
Electorate
Investor
Tenacious
Unsung Hero

EDIT: tweaked it a bit.

share|improve this answer
    
I count 189 characters... –  Doorknob Jan 4 at 13:52
    
Bash - huehuehue. PS is /dev/null really needed here? –  Ultra Jan 4 at 14:20
    
You can use curl instead of wget -O-. –  xfix Jan 4 at 15:03
    
Hmm I thought that I had removed the /dev/null which I had for testing. –  Thom Wiggers Jan 4 at 20:36
add comment

PHP - 92 86 characters

<?=html_entity_decode(substr(file_get_contents("http://tinyurl.com/q9zlwfr"),12937,190));

Inspired by Victor's solution. Very volatile.

share|improve this answer
add comment

Java - 280 267 260

class A{public static void main(String[]z)throws Exception{String s="";int y;java.io.InputStream x=new java.net.URL("http://tinyurl.com/q9zlwfr").openStream();while((y=x.read())!=-1)s+=(char)y;System.out.println(s.substring(12937,13126).replace("amp;",""));}}
share|improve this answer
1  
That seems... volatile. If Stack Exchange team would make almost any change to their website (or if my question would be modified), it would return the wrong list. Besides, the list may be not up to date. –  xfix Jan 4 at 18:52
    
Why is the class name so long? Why is the argument to main's name so long? Why is there unnecessary whitespace after InputStream? –  Doorknob Jan 4 at 18:52
    
@DoorknobofSnow Well noted. These one slipped when I was converting the ungolfed version to a golfed one. –  Victor Jan 4 at 18:55
    
@xfix Yeah, very volatile. That was intentional. –  Victor Jan 4 at 19:10
    
I'm tempted to edit the question by one letter just to troll you :-D –  Doorknob Jan 4 at 19:14
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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