I hereby claim:
- I am jfkelley on github.
- I am joefkelley (https://keybase.io/joefkelley) on keybase.
- I have a public key whose fingerprint is 37CA 2BA0 7ECE 3F14 5B87 4436 54B6 4CF0 1AEE D71B
To claim this, I am signing this object:
// All of the ways that a subset of xs can sum to target | |
def sumTo(xs: List[Long], target: Long, acc: Set[Long]): LazyList[Set[Long]] = { | |
if (target == 0) { | |
LazyList(acc) | |
} else if (target < 0) { | |
LazyList.empty | |
} else xs match { | |
case head :: rest => { | |
sumTo(rest, target - head, acc + head) ++ sumTo(rest, target, acc) | |
} |
def pWin(p, f, t, cache): | |
if (f, t) in cache: | |
return cache[(f, t)] | |
if t > f: | |
return 1.0 | |
if t < f * -2: | |
return 0.0 | |
one = p * pWin(p, f-1, t+1, cache) + (1-p) * pWin(p, f-1, t-1, cache) | |
two = 0.5 * pWin(p, f-1, t+2, cache) + 0.5 * pWin(p, f-1, t-2, cache) | |
x = max(one, two) |
counts = {} | |
enable_doubling = False # change to true for extra credit | |
def count_possible_bids(current_bid, n_passes, n_doubles): | |
if (n_passes == 3 and current_bid != -1) or n_passes == 4: | |
return 1 | |
if (current_bid, n_passes, n_doubles) in counts: | |
return counts[(current_bid, n_passes, n_doubles)] | |
result = 0 | |
for n in range(current_bid + 1, 28): |
statements = [ | |
('a', 'b', lambda x: x > 20), | |
('b', 'c', lambda x: x > 18), | |
('c', 'd', lambda x: x < 22), | |
('d', 'e', lambda x: x != 17), | |
('e', 'a', lambda x: x > 21), | |
('a', 'd', lambda x: x > 16), | |
('b', 'e', lambda x: x < 20), | |
('c', 'a', lambda x: x == 19), | |
('d', 'b', lambda x: x == 20), |
def threes(board): | |
for x in [0, 1, 2]: | |
yield [board[x][0], board[x][1], board[x][2]] | |
yield [board[0][x], board[1][x], board[2][x]] | |
yield [board[0][0], board[1][1], board[2][2]] | |
yield [board[0][2], board[1][1], board[2][0]] | |
def is_done(board): | |
for th in threes(board): | |
if th[0] is not None and th[0] == th[1] and th[1] == th[2]: |
I hereby claim:
To claim this, I am signing this object:
200 | |
J1 | |
J2 | |
J3 | |
J4 | |
J5 | |
J6 | |
J7 | |
J8 | |
J9 |