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
| #[test] | |
| fn test_something_interesting() { | |
| run_test(|| { | |
| let true_or_false = do_the_test(); | |
| assert!(true_or_false); | |
| }) | |
| } | |
| fn run_test<T>(test: T) -> () | |
| where T: FnOnce() -> () + panic::UnwindSafe |
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
| package rfc3339; | |
| import org.junit.jupiter.api.Assertions; | |
| import org.junit.jupiter.api.Test; | |
| import org.junit.jupiter.api.function.Executable; | |
| import java.time.ZoneOffset; | |
| import java.time.ZonedDateTime; | |
| import java.time.format.DateTimeFormatter; | |
| import java.time.format.ResolverStyle; |
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
| hazelcast.hosts={{ groups.api|zip_longest([], fillvalue=':5701')|map('join')|join(',') }} | |
| endpoint.hosts={{ ['http://']|product(groups.query_gui)|map('join')|product([':8099'])|map('join')|join(',') }} |
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
| class EnoughParticipantsMonteCarlo extends EnoughParticipants { | |
| override def calculate(probabilities: List[Double], needed: Int): Double = { | |
| (1 to attempts).par.map(i => probabilities.map(p => dice(p)).sum).count(successful => successful >= needed) / attempts.toDouble | |
| } | |
| val Precision = 0.001 | |
| val attempts = Math.ceil(Math.pow(1 / Precision, 2)).toInt |
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
| trait EnoughParticipants { | |
| /** Given probabilities of each participant attending in "probabilities", | |
| * calculate the probability that at least "needed" participants will participate. | |
| * | |
| * The probability has to be accurate to the precision of 0.001. | |
| */ | |
| def calculate(probabilities: List[Double], needed: Int): Double | |
| } |
NewerOlder