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 math | |
evalue = [0] * 181 | |
norm = math.comb(180, 4) | |
for i in range(1, 181): | |
ans = math.comb(i, 0) * math.comb(180 - i, 4 - 0) / norm | |
for k in range(1, 5): | |
if i - k >= 0: | |
px = math.comb(i, k) * math.comb(180 - i, 4 - k) / norm |
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
row[n_] := Table[ | |
Binomial[n, 4-(k-n)] Binomial[180-n, k-n] / Binomial[180, 4], | |
{k, 0, 180}] | |
m = Table[row[k], {k, 0, 180}] | |
r = m[[1;;180, 1;;180]] | |
Print[N[Total[Inverse[IdentityMatrix[180] - r][[1]]]]] |
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
KERNELDIR=/lib/modules/`uname -r`/build | |
#ARCH=i386 | |
#KERNELDIR=/usr/src/kernels/`uname -r`-i686 | |
MODULES = db9.o | |
obj-m += db9.o | |
all: | |
make -C $(KERNELDIR) M=$(PWD) modules |
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 to_base(n, base): | |
ans = [] | |
while n > 0: | |
ans.append(n % base) | |
n //= base | |
return ans | |
def is_palin(n): | |
return n == n[::-1] |
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 itertools | |
import sys | |
from fractions import Fraction | |
def split_integer(n): | |
for a in range(1, 1 + n // 2): | |
yield a, n - a | |
def resistor_pairs(n, cur_list): | |
for a, b in split_integer(n): |
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
count[graph_, pos_, 0] := 1 | |
count[graph_, pos_, size_] := Sum[ | |
If[graph[[i, pos]] == 1, count[graph, i, size - 1], 0], | |
{i, 1, Length[graph]}] |
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
// Number of n-step paths made by a chess king, starting from the corner of an infinite chessboard, and never revisiting a cell. | |
// OEIS A300665 | |
// Ricardo Bittencourt, March 13 2018 | |
package main | |
import "fmt" | |
type Grid struct { | |
grid []bool |
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
// Number of n-step paths made by a chess king, starting from the corner of an infinite chessboard, and never revisiting a cell. | |
// OEIS A300665 | |
// Ricardo Bittencourt, March 11 2018 | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
struct Grid { |
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
#define STATE_CAPA 0 | |
#define STATE_RACE 1 | |
#define STATE_CAPA_FADEIN 2 | |
#define STATE_CAPA_FADEOUT 3 | |
#define STATE_SELECT 4 | |
#define STATE_CHAR_SELECT 5 | |
#define STATE_DRAW_TRACK 6 | |
#define STATE_SHOP 7 | |
#define STATE_CREDITS 8 | |
#define STATE_PODIUM 9 |