Created
November 17, 2017 12:06
-
-
Save msikma/966949c21de840698ff878788e29bdcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculates win percentage of makuuchi matches on sumodb. | |
// use on e.g. http://sumodb.sumogames.de/Rikishi.aspx?r=1123 where it should yield "84.9" as of now. | |
// losses by default are excluded, but wins by default are included; as is standard in sumo records. | |
$("tr").map((n, tr) => { | |
const k = $("td.cat", tr); | |
const v = $("td.val", tr); | |
if (k.text().toLowerCase().indexOf("in makuuchi") !== 2) { | |
return; | |
} | |
const r1 = v.text().split(" "); | |
const r2 = r1[0].split("/"); | |
const r3 = r2[0].split("-"); | |
const wins = Number(r3[0]); | |
const losses = Number(r3[1]); | |
const percentage = (wins / (wins + losses) * 100).toFixed(1); | |
console.log(percentage); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment