Skip to content

Instantly share code, notes, and snippets.

View Goodwine's full-sized avatar

Carlos (Goodwine) Goodwine

View GitHub Profile
@Goodwine
Goodwine / probs.js
Created January 24, 2016 00:07
How many times do I need to try something that has an `odds` probability of winning to ensure with a certain level of `confidence` that I'll win.
function rolls(odds, confidence) {
var prob = 0;
for (var n = 0; prob < confidence;) {
n++;
prob += calcProb(1, odds) * calcProb(n-1, 1-odds);
}
return n;
}
function calcProb(times, odds) {
@Goodwine
Goodwine / updateCoderPlacement O(n*log2(n))
Created December 1, 2014 01:38
Gist Shows the *Proposed* implementation of how TopCoder assigns placement in a room.
x = [];
n = 35000;
for (i = 0; i < n; i++) {
x.push({
userName: Math.random(),
totalPoints: Math.random() * 100000,
})
}
@Goodwine
Goodwine / updateCoderPlacement O(n^2)
Created December 1, 2014 01:10
Gist Shows the current implementation of how TopCoder assigns placement in a room.
x = [];
n = 35000;
for (i = 0; i < n; i++) {
x.push({
userName: Math.random(),
totalPoints: Math.random() * 100000,
})
}