Skip to content

Instantly share code, notes, and snippets.

View alecgrieser's full-sized avatar

Alec Grieser alecgrieser

View GitHub Profile
@alecgrieser
alecgrieser / bagels.py
Created July 26, 2016 06:38
Bagels Problem Solver
import argparse
# The approach I thought of first. It uses a DP technique
# where the number of ways to fit t types of bagels into
# s slots is computed for every t up to and inluding the
# number of bagel types and for every s up to and including
# the number of slots to fill.
# Running time: Theta(types*(slots)^2) (pseudo-polynomial).
def calculate_ways(types, slots):
if types == 0: return 0
@alecgrieser
alecgrieser / overflow-eq.cl
Created June 6, 2016 15:02
Math overflow problem in Cool equality
class Main inherits IO {
main() : SELF_TYPE {
{
out_eq(2147483647+2147483647, ~2);
out_eq(2*2147483647, ~2);
}
};
out_eq(a : Int, b : Int) : SELF_TYPE {
out_int(a).out_string(" = ").out_int(b).out_string(" <==> ")
@alecgrieser
alecgrieser / random-math.cl
Created May 8, 2016 21:59
Random Math Cool Difference
class Randr inherits IO {
-- Random seed.
x : Int <- {
out_string("Please provide a random seed: ");
in_int();
};
-- Parameters into the PRNG.
a : Int <- 1103515245;
c : Int <- 12345;
@alecgrieser
alecgrieser / busybeaver3.in
Last active April 7, 2016 02:26
Turing Machine in Cool
3
1
1
1
1
2
-1
1
0
-1
1. Club & Claws
2. Nail & Gear
3. Flaggy Flag
4. White Cross
Find an electronic version at tinyurl.com/grieser-vote
My identity can be verifed at keybase.io/verify.
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1

Keybase proof

I hereby claim:

  • I am alecgrieser on github.
  • I am grieser (https://keybase.io/grieser) on keybase.
  • I have a public key whose fingerprint is 4DE8 5BE4 79F8 4F7B D685 A108 D71F 2282 088F 754A

To claim this, I am signing this object: