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
// [dependencies] | |
// pin_project = "1" | |
// tokio = { version = "1", features = "time" } | |
// hyper = { version = "1" } | |
use std::{pin::Pin, task::{Context, Poll}, time::Duration}; | |
use std::future::Future; | |
use tokio::{io::{AsyncRead, AsyncWrite}, time::Sleep}; | |
use pin_project::pin_project; |
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
/** | |
* @param p {number} - The total number of different possibilities (days in a year) | |
* @param n {number} - The number of occurrences (number of people) | |
* @returns {number} - The probability of at least two people having the same birthday. @min 0 - @max 1 | |
*/ | |
export const birthday_problem = (p, n) => { | |
let acc = 1; | |
for(let i = 1; i < n; i++) { | |
acc *= (1 - ( i / p )); |