This file has been truncated, but you can view the full file.
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
| 0 = 0 | |
| 1 = 1 | |
| 2 = 2 | |
| 3 = 3 | |
| 4 = 4 | |
| 5 = 5 | |
| 6 = 6 | |
| 7 = 7 | |
| 8 = 8 | |
| 9 = 9 |
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
| / - / : WINS: none | LOSSES: none | DRAWS: 1, 2, 3, 4, 5, 6, 7, 8 | |
| / - 1 : WINS: none | LOSSES: none | DRAWS: 2, 3, 4, 5, 6, 7, 8 | |
| / - 2 : WINS: none | LOSSES: 1, 3, 4 | DRAWS: 5, 6, 7, 8 | |
| / - 3 : WINS: none | LOSSES: 1, 2, 6 | DRAWS: 4, 5, 7, 8 | |
| / - 4 : WINS: none | LOSSES: 1, 2, 7 | DRAWS: 3, 5, 6, 8 | |
| / - 5 : WINS: none | LOSSES: 1, 3, 7 | DRAWS: 2, 4, 6, 8 | |
| / - 6 : WINS: none | LOSSES: 1, 2, 3, 4, 7, 8 | DRAWS: 5 | |
| / - 7 : WINS: none | LOSSES: 1, 4, 8 | DRAWS: 2, 3, 5, 6 | |
| / - 8 : WINS: none | LOSSES: 1, 2, 3, 4, 6, 7 | DRAWS: 5 | |
| 1 - 2 : WINS: none | LOSSES: 3 | DRAWS: 4, 5, 6, 7, 8 |
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
| def g0(sx, sy, px, py, cache): | |
| if sx < min(px, py) or sy < min(px, py): | |
| return 0 | |
| if sx*sy < px*py: | |
| return 0 | |
| if sx*sy == px*py: | |
| return 1 if (sx==px and sy==py) or (sx==py and sy==px) else 0 | |
| best = 0 | |
| for i in range(1, sx): | |
| best = max(best, guillotine(i, sy, px, py, cache) + guillotine(sx-i, sy, px, py, cache)) |
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 main | |
| import ( | |
| "fmt" | |
| "testing" | |
| "github.com/db47h/rand64/xoroshiro" | |
| ) | |
| const N = 10_000_000 |
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
| #include <stdio.h> | |
| int main() { | |
| int result = 1; | |
| int n = 17; | |
| for (int i=0; i < (2^64); i++) { | |
| result = (result * n) % 115763; | |
| } | |
| printf("%d\n", result); | |
| return 0; |
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
| diff --git a/triangle.c b/triangle.c | |
| index f9e23fa..06cba71 100644 | |
| --- a/triangle.c | |
| +++ b/triangle.c | |
| @@ -342,11 +342,8 @@ | |
| #define ONETHIRD 0.333333333333333333333333333333333333333333333333333333333333 | |
| - | |
| -#include <inttypes.h> |
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
| def concat_optimal(xs, i=0, j=None, cache=None): | |
| if cache is None: | |
| i, j, cache = 0, len(xs), dict() | |
| if (i, j) not in cache: | |
| cache[i, j] = concat_optimal0(xs, i, j, cache) | |
| return cache[i, j] | |
| def concat_optimal0(xs, i, j, cache): | |
| if j == i+1: | |
| return 0, xs[i], i |
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
| def primes(n): | |
| x = [False] * (n + 1) | |
| for i in xrange(2, n + 1): | |
| if x[i]: continue | |
| yield i | |
| for j in xrange(2 * i, n + 1, i): | |
| x[j] = True | |
| def prime_pairs(n): | |
| ps = list(primes(n)) |
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
| # Player A and B each get a number from 0 to n-1. | |
| # Player A can: | |
| # check: -1, 0, +1 | |
| # raise: B fold then +1 | |
| # : B call then -2, 0, +2 | |
| # strat[i] is probability that A raises with hand i. | |
| # Then counterB(n, strat) gives B's optimal counter strategy. | |
| def counterB(strat): | |
| n = len(strat) | |
| result = [] |
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
| import itertools | |
| import random | |
| def power_two(x): | |
| return x and (x & (x - 1) == 0) | |
| def asort(A, i, j): | |
| assert power_two(j - i + 1), '%d - %d + 1 not power of 2' % (j, i) | |
| if A[i-1] > A[j-1]: | |
| A[i-1], A[j-1] = A[j-1], A[i-1] |
NewerOlder