This question is inspired by the fact that I love seeing questions with equal vote and answer counts...

So here's a simple challenge for y'all:

Challenge:

Specifics:

• You may access the internet, but you may only access stackexchange.com and its various sub-domains. You may not use URL shorteners.

• You may take input and give output in any standard format.

• You must output the ratio as a decimal number in base 10, with at least 4 {accurate} digits after the decimal (zeros may be truncated).

• If the question is unanswered, your program may produce undefined behavior.

• You should use the score of the question as the vote-count, see here.

This is , least bytes in each language wins for that language, least bytes overall wins overall.

Here is a sample program in Python 3 + requests:

import requests
import json

id = input("id> ")
url = "https://api.stackexchange.com/2.2/questions/" + id + "?site=codegolf"
content = requests.get(url).text

• Does the ratio need at least 4 decimal digits after the decinal point even if they are zero? E.g. 41/4= 10.25 or 10.2500 Sep 18 '17 at 15:19
• @pizzapants184 10.25 is fine Sep 18 '17 at 15:21
• What if the challenge is not answered? Then the ratio would be infinite? Sep 18 '17 at 15:37
• Do you mean score or total votes on the question? Sep 18 '17 at 15:37
• @Mr.Xcoder in that case, undefined behavior is okay Sep 18 '17 at 15:37

JavaScript (ES6), 103 102 bytes

Needs to be run from the root level of api.stackexchange.com. Returns a Promise object containing the result.

n=>fetch(questions/${n}?site=codegolf).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count) If requiring that it be run from a specific path is allowed then that becomes 92 90 bytes. n=>fetch(n+?site=codegolf).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count) Try it Full URL added to enable it to work here. f= n=>fetch(//api.stackexchange.com/questions/${n}?site=codegolf).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)
onchange=_=>f(+i.value).then(t=>o.innerText=t)
<input id=i type=number><pre id=o>

• Replace i=>(j=i.items) with ({items:[j]})=>j to save a byte. Sep 18 '17 at 20:14
• Nice trick, thanks, @kamoroso94. I'll have to remember that one. Sep 18 '17 at 22:25

Stratos, 40 bytes

-4 bytes thanks to Shaggy

f"¹⁵s/%²"r"⁷s"@0
⁰s"score"/

Try it!

Stratos specialises in questions.

Explanation:

The code decompresses to the following:

f"api.stackexchange.com/questions/%?site=codegolf"r"items"@0
⁰s"score"/

Starting from the first line, Stratos evaluates the dyads from right to left.

f"api.stackexchange.com/questions/%?site=codegolf"r"items"@0 means "evaluate the dyad @ with the left-hand argument f"api.stackexchange.com/questions/%?site=codegolf"r"items" and the right-hand argument 0. @ gets the nth element of a JSON array.

To evaluate f"api.stackexchange.com/questions/%?site=codegolf"r"items", we will next evaluate the dyad r with the left-hand argument f"api.stackexchange.com/questions/%?site=codegolf" and the right-hand argument "items". r gets the JSON array with the specified name.

Next, we will need to evaluate f"api.stackexchange.com/questions/%?site=codegolf". First, % is replaced with the input. f means "get the contents of this URL".

Now, we can move on to the second line. The newline means "add what we evaluated to the implicit argument list"

Next, we evaluate s (get string in JSON object with a certain name) with { and "answer_count". { takes an element from the implicit argument stack, returns it, and adds it back to the stack.

Then, we add the output of that to the implicit argument stack.

To evaluate ⁰s"score"/, we are applying the dyad / (divide) to ⁰s"score" and an element from the implicit argument stack.

To evaluate ⁰s"score" we are getting the string "score" from the JSON object from the 0th element in the implict argument stack.

Now, the output of / is printed and the program terminates.

• Save 4 bytes by ditching the API version (2.2/). Sep 18 '17 at 17:14
• @Shaggy Didn't realise the API version wasn't required, thanks. Not crossing out 44 :P
– Okx
Sep 18 '17 at 17:18

Performs an Invoke-WebRequest against the URL, gets the .content thereof, does a ConvertFrom-Json of that content, and gets the .items of that JSON object. Stores that into $a and pulls out the .score as the numerator. The denominator is the .answer_count. That value is left on the pipeline and output is implicit. If the question is unanswered, this should toss a "Divide by zero" error. Japt, 83 82 bytes Wanted to give this a try to see how it would work out, seeing as Japt can't natively accomplish it. Essentially all this is doing is evaling a compressed version of my JS solution. As Japt is JS then we can require that this be run from the root level of api.stackexchange.com and also return a Promise object containing the result. Ox`fet®("quÀËs/{U}?ÐÒ=¬¸golf").È(r=>r.js()).È(i=>(j=i.ems).sÖ/j.s³r_Öt) • View it • Try it - the extra bytes in this version are accounted for by the inclusion of //api.stackexchange.com/ in the URL and of console.log so you can actually see it working • o0 Why have you made the code a link? It even messes with the userscript's byte count display lol. i.imgur.com/SO2zgAy.png Sep 18 '17 at 20:54 Mathematica, 124 bytes N@("score"/.(u="items"/.Import["http://api.stackexchange.com/questions/"<>#<>"?site=codegolf","JSON"]))/("answer_count"/.u)& Mathematica has a data type called Rule and it confuses the heck out of me. :P Python 3 + requests, 149 bytes -1 byte thanks to Mr. Xcoder. from requests import* u=get('http://api.stackexchange.com/questions/%s?site=codegolf'%input()).json()['items'] print(u['score']/u['answer_count']) • The link is to Python 2. Btw, it throws an error both in Python 2 and Python 3 (on TIO). – user72349 Sep 18 '17 at 15:38 • No internet access on TIO whoops. I just used TIO for the answer formatting lol. Sep 18 '17 at 15:42 • I think that (for now) http suffices. Sep 18 '17 at 15:49 • 125 bytes Sep 19 '17 at 9:27 PHP, 167 bytes <?$f=json_decode(gzdecode(file_get_contents('https://api.stackexchange.com/2.2/questions/'.$argv.'?site=codegolf')))->items;echo$f->score/\$f->answer_count;

Turbo-fast crack at this. Save as a file and execute in the terminal like so:

php -f file.php 143083

Might be a way to reduce this.