Post an answer to this question that evaluates any answer to this question and determines whether it wins.
Who wins:
- Winner is the answer that wins according to the most answers at 1700 UTC, Sunday, March 2nd.
- You are welcome to and encouraged to change your own answer as the contest progresses. Please do not change others'.
- Ties are determined by the shortest code.
- Regardless of how much sockpuppeting you might normally do, if something's fishy, I'm gonna disqualify you.
- I will not accept my own answer, but I will use it to evaluate yours.
Rules:
- Your calculation must provide a numeric score for any arbitrary answer (to make it easy, the input to your algorithm is either the id of the answer or the markdown of the answer on the page).
- Your score must have at least one winner, and it must be possible for an answer besides yours to win.
- Your algorithm cannot use something very specific to your answer, nor can username or timestamps be used at all. I will be the final judge of what "very specific" means, but I encourage community policing and public shaming.
- Your code must compile, run, and give a score given any answer.
- Please include a link to a way to execute your code if it is not listed on Ideone. See below.
Ideone languages
-
1\$\begingroup\$ Any special reason for the "Please only contribute one answer" restriction? If I develop two very different algorithms with two very different criteria, can't I post both? \$\endgroup\$Victor Stafusa– Victor Stafusa2014年02月12日 05:47:10 +00:00Commented Feb 12, 2014 at 5:47
-
\$\begingroup\$ @Victor I guess you're right. I can ease up on that rule, but I will shut folks down for stacking the deck. \$\endgroup\$Not that Charles– Not that Charles2014年02月12日 06:11:34 +00:00Commented Feb 12, 2014 at 6:11
-
\$\begingroup\$ Should the winner correctly determine that it is itself the winner? I.E, if answers A, B and C says that D is the winner, but D says that A is the winner, is D the winner even if it is a wrong answer? \$\endgroup\$Victor Stafusa– Victor Stafusa2014年02月12日 06:23:26 +00:00Commented Feb 12, 2014 at 6:23
-
\$\begingroup\$ @Victor The winner doesn't have to be correct. That would be way too hard. \$\endgroup\$Not that Charles– Not that Charles2014年02月12日 06:44:04 +00:00Commented Feb 12, 2014 at 6:44
-
\$\begingroup\$ Since when does Ideone allow network access? \$\endgroup\$user344– user3442014年02月19日 14:09:30 +00:00Commented Feb 19, 2014 at 14:09
4 Answers 4
R, 1 char
1
You can supply the id of an answer as a command line argument if you wish. :) Link to ideone.
Further elaboration
Since it is not practical for an answers to execute other answers (different languages, etc.) and evaluate them based on their result the only remaining way I can see for them to give a score is to use some code metric.
I have noticed that all other answers so far give a higher score to shorter programs. I believe this is the shortest code possible so it should rank high in the result of other answers.
How and what answer my code gives for other answers seams to be less relevant. The only important aspect is that others rank my answer high.
-
\$\begingroup\$ Please elaborate. \$\endgroup\$rahulroy9202– rahulroy92022014年02月19日 03:49:42 +00:00Commented Feb 19, 2014 at 3:49
-
1\$\begingroup\$ @rahulroy9202 Updated answer with my reasoning. \$\endgroup\$Andris– Andris2014年02月19日 12:13:55 +00:00Commented Feb 19, 2014 at 12:13
-
2\$\begingroup\$ :D good point. Your assumptions are logical. Unless someone figures out a way to print 1 with no code at all. :D \$\endgroup\$rahulroy9202– rahulroy92022014年02月19日 12:18:36 +00:00Commented Feb 19, 2014 at 12:18
-
\$\begingroup\$ @rahulroy9202 I think it is not possible to post a blank code block so even if this is possible in a language you could not post the "code" here. :D \$\endgroup\$Andris– Andris2014年02月19日 12:27:10 +00:00Commented Feb 19, 2014 at 12:27
-
\$\begingroup\$ try <code></code> inside answer and my code will read it as 0 char answer. :D \$\endgroup\$rahulroy9202– rahulroy92022014年02月19日 12:28:57 +00:00Commented Feb 19, 2014 at 12:28
R, 1 char
0
Following up on @Andris's answer, there are now two codes that have a single character: Andris's and mine. Since we tie in the eyes of the other answers, neither of us have "won" outright, so my answer won't "win". :-)
Ruby, 368 char
require 'json'
require 'open-uri'
v='body';w="#{v}_markdown";s='comments'
x=if(d=JSON.parse(open("http://api.stackexchange.com/2.2/answers/#{ARGV[0]}?site=codegolf&filter=!%29r%28UkmOhmCPjXru-TDty").read)['items'][0]).include?(s) then d[s].map{|c|c[w].length*[1,c[w].index('`')||1,c[w].index('\n')||1].max}.reduce(:+) else -2 end
puts d['score']*150+5*(d[v].match(/<(..).*?1円.*?1円/m))[0].ord+x-$~.end(0)
Good luck!
JavaScript- 190 char
Assumption: The first code block is the answer.
var ans=$('.answer'),s=999,sa;
for(i=0;i<ans.length;i++){
var x = ans[i].getElementsByTagName('code');
var z = x[0].innerHTML.replace(/\s/g,'').length;
if(s>z){
s=z;
sa=ans[i];
}
}
console.log(sa);
Can be tested in browser console. It assumes the shortest answer to be the correct answer.
How to execute- On Chrome/Firefox open console while on this page and paste code and execute.
-
\$\begingroup\$ It also works in the IE 11 console :) \$\endgroup\$ComFreek– ComFreek2014年02月19日 14:04:10 +00:00Commented Feb 19, 2014 at 14:04