Skip to content

Instantly share code, notes, and snippets.

package hod
import java.text.DecimalFormat
import scala.collection.{IndexedSeq, mutable}
import scala.collection.Searching._
object Euler352 {
type Decimal = Double
sealed trait ComparisonResult
T(1, 0.02) = 1.0
T(2, 0.02) = 1.0596
T(3, 0.02) = 1.138408
T(4, 0.02) = 1.2364318400000003
T(5, 0.02) = 1.3336872032000002
T(6, 0.02) = 1.4497816191360005
T(7, 0.02) = 1.5655223067532802
T(8, 0.02) = 1.699732497418215
T(9, 0.02) = 1.8140031210698506
T(10, 0.02) = 1.9463808027124538
def calculateChanceOfNegativeResultInPositiveGroup(testSize: Int, totalSize: Int): Decimal = {
val allHealthy = scenario.goodSampleChance.pow(totalSize)
val atLeastOneSick = 1 - allHealthy
val factor = 1 / atLeastOneSick
val probabilityOfPositiveResult = {
val negatives = testSize
val negativeResults = negatives
val probabilityOfEvent = {
val negativeInThisCase = negatives
val times = 1
package hod
import scala.collection.mutable
import scala.util.Random
object Euler493 {
val poolSize = 70
val colors = 7
val picks = 20
val initialOptionsPerColor: Int = poolSize / colors
@HamsterofDeath
HamsterofDeath / euler352fail
Created April 27, 2018 18:11
where is the bug?
/usr/lib/jvm/java-9-oracle/bin/java -javaagent:/home/hamsterofdeath/devtools/idea-IU-181.4668.1/lib/idea_rt.jar=36343:/home/hamsterofdeath/devtools/idea-IU-181.4668.1/bin -Dfile.encoding=UTF-8 -classpath /home/hamsterofdeath/eulerproblems/out/production/eulerproblems:/home/hamsterofdeath/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.5.jar:/home/hamsterofdeath/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.5.jar:/home/hamsterofdeath/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.12.5-sources.jar:/home/hamsterofdeath/.ivy2/cache/org.scala-lang/scala-reflect/srcs/scala-reflect-2.12.5-sources.jar hod.Euler352
Testing 25 of 25, expecting 3.120106971480634 more tests.
If positive (39.65%), do
Testing 12 of 25, expecting 6.8684223215274125 more tests.
If positive (48.00%), do
Testing 6 of 12, expecting 4.646206499949302 more tests.
If positive (50.00%), do
Testing 3 of 6, expecting 2.9223248658666665 more tests.
If positive (50.0
package ai
/**
* Created by HamsterofDeath on 3/14/2017.
*/
import java.text.DecimalFormat
import scala.util.Random
object BenchIt {
@HamsterofDeath
HamsterofDeath / Youtube.scala
Created April 9, 2016 13:15
Can You Solve The Dice Rolling Drinking Game?
package pony.tmp
import java.security.SecureRandom
import scala.util.Random
/**
* Created by HamsterofDeath on 4/9/2016.
*/
object Youtube {
@HamsterofDeath
HamsterofDeath / substring
Created January 13, 2016 13:57
substring
def isSubString(check: String, sub: String) = {
sub.headOption.fold(false) { begin =>
val min = sub.length
val max = check.length
check.iterator
.zipWithIndex
.collect {
case (c,i) if c == begin && i + min <= max => i
}.exists { where =>
val zipped = check.drop(where).iterator.zip(sub.iterator)
05,10% = 217.24976
05,20% = 217.21588
05,00% = 217.16324
04,90% = 217.08532
04,80% = 217.05248
04,70% = 217.02228
05,30% = 216.98688
04,60% = 216.93892
05,50% = 216.89772
05,40% = 216.78528
0.05% = 217.15676
0.048% = 217.14268
0.052% = 217.1088
0.047% = 217.08588
0.051% = 217.06532
0.049% = 217.0166
0.053% = 216.95008
0.046% = 216.8714
0.054% = 216.79872
0.045% = 216.65844