Instantly share code, notes, and snippets.

# Jason Liszka jliszka

Last active August 14, 2022 12:28
View fruit.py
This file contains 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
 N=4 def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a class Q(object): def __init__(self, p, q=1):
Created February 3, 2022 19:46
View parser.php
This file contains 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
 ::= "+" | "-" |
Last active November 30, 2018 15:33
View mystery.scala
This file contains 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
 // Multinomial formula def multi(ks: Vector[Int]): Double = { (1 to ks.sum) .map(_ / ks.size.toDouble) .zip(ks.flatMap(1 to _)) .map({ case (n, d) => n / d }).product } // Expected number of cereal boxes you have to buy if you want to collect at least `m` of each of `n` surprise mystery toys def e(n: Int, m: Int, M: Int = 20, v: Vector[Int] = Vector.empty): Double = {
Last active January 18, 2016 16:08
This file contains 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
 def basketball(unseenShots: Int) = { def prob(outcomes: List[Boolean]) = 1.0 * outcomes.count(m => m) / outcomes.size val outcomes = always(List(true, false)).markov(unseenShots+1)(outcomes => tf(prob(outcomes)).map(b => b::outcomes)).given(_.head) val lastShot = for { outcome <- outcomes shot <- tf(prob(outcome)) } yield shot lastShot.pr(a => a) }
Created January 12, 2016 04:18
View car.py
This file contains 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
 from itertools import permutations import pprint class Strategy: def cards(self, cs): return False def filter(self, p): return True
Last active August 29, 2015 14:08
View JavaEmbeddedRecord.java
This file contains 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 JavaEmbeddedRecord { public UserId getId() { return (UserId)(new Long(5)); } }
Last active August 29, 2015 14:02
View benchmarks.scala
This file contains 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
 import scala.collection.mutable.WrappedArray abstract class Impl(val name: String) { val N = 20000 val R = 100 def setup(n: Int): Unit = () def run(n: Int): Unit
Last active December 31, 2015 17:09
Code for "Bayesian models and causality"
View Examples.scala
This file contains 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