Skip to content

Instantly share code, notes, and snippets.

@iliakonnov
Last active August 21, 2020 16:06
Show Gist options
  • Save iliakonnov/d50607e6909de6e62caed1abbf5a615b to your computer and use it in GitHub Desktop.
Save iliakonnov/d50607e6909de6e62caed1abbf5a615b to your computer and use it in GitHub Desktop.
(function(my_name_is) {
let head_table = $("table").rows[1].cells;
let luckies = parseInt(head_table[0].textContent) + parseInt(head_table[1].textContent);
let enemies = $("table.tableFixHead").rows;
let my_points = 0;
let my_place = 0;
let suspicious = 0;
let better_than_me = 0;
let fat_people = 0;
for (let i=1; i<enemies.length; i++) {
let row = enemies[i].cells;
let points = row[row.length - 2];
if (row[3].textContent == my_name_is) {
my_points = parseInt(points.textContent);
my_place = i;
break;
}
let others = row[row.length - 1].children;
let skip_him = false;
for (let j = 0; j < others.length; j++) {
if (others[j].tagName == "B") {
skip_him = true;
}
}
if (skip_him) {
continue;
}
better_than_me += 1;
let is_fat = row[0].children.length != 0;
if (is_fat) {
fat_people += 1;
} else {
suspicious += 1;
}
}
console.log(`[${my_place}] Меня зовут ${my_name_is} и я набрал ${my_points} баллов.`)
console.log(`КЦП: ${luckies}`);
console.log(`Меня обогнало: ${better_than_me}`);
console.log(`Неопределившихся: ${suspicious}`);
console.log(`Уже определились: ${fat_people}`);
// (S-x) + F = L — solve for x
// S+F == BTM
let to_terminate = better_than_me - luckies;
console.log(`Надо чтобы не подавали: ${to_terminate}`);
console.log(`Т.е. ${to_terminate / suspicious * 100}% от неопределившихся`);
})("Иванов Иван Иванович");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment