Skip to content

Instantly share code, notes, and snippets.

@msikma
Created November 17, 2017 12:06
Show Gist options
  • Save msikma/966949c21de840698ff878788e29bdcf to your computer and use it in GitHub Desktop.
Save msikma/966949c21de840698ff878788e29bdcf to your computer and use it in GitHub Desktop.
// 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