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 numpy as np | |
def runSimulation(N): | |
judge_num = np.zeros(N, dtype=np.int) | |
for i in range(9): | |
judge_num[:(np.random.randint(0, 41))] += 1 | |
for i in range(4, N, 4): | |
if np.random.random() > 0.5: |
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 numpy as np | |
import time | |
import matplotlib.pyplot as plt | |
def isConvex(dx, dy): | |
for j in range(4): | |
if dx[j]*dy[(j+1) % 4] < dy[j]*dx[(j+1) % 4]: | |
return False | |
return True |
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
The player that places first is guaranteed to win, as long as he/she uses the optimal strategy. | |
Winning Strategy | |
---------------- | |
1. First player begins by placing the first coin right right at the center of the table | |
2. Second player places a coin anywhere on the table | |
3. First player tries to mimic second player's coin in the following way: | |
Imagine rotating the table about the center by 180 degrees, then place the coin where the second player's coin was before the rotation. | |
Done correctly, this newly placed coin makes the table look identical under a 180 degrees rotation about the center. | |
4. If there is no more space on the table, first player wins. Otherwise go back to Step 2. |
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
from keras.datasets import mnist | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout, Activation, Flatten, normalization, Convolution2D, MaxPooling2D | |
from keras.utils import np_utils | |
import matplotlib.pyplot as plt | |
from sklearn import metrics | |
import numpy as np | |
# input image dimensions |
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
calcLimitingProb[K_] := | |
Module[{p, n, plose, pdrop, pwin, tmp, solution}, | |
p = {(999 K)/(1000 + 999 K)}; | |
solution = {N[1000/999]}; | |
For[n = 2, n <= 20, n++, | |
pdrop = (K*Sqrt[n]/1000)*(999/1000)^n; | |
plose = 1 - (999/1000)^n + (1 - p[[n - 1]])*pdrop; | |
pwin = p[[n - 1]]*pdrop; | |
tmp = Simplify[pwin/(plose + pwin)]; |
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 math | |
import matplotlib.pyplot as plot | |
def generate_path(speed, num_steps): | |
scaled_step = speed/num_steps | |
step = 1.0/num_steps | |
ram_x = [0] * (num_steps + 1) | |
ram_y = [0] * (num_steps + 1) |
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 numpy as np | |
import math | |
import matplotlib.pyplot as plot | |
import time | |
def gen_rand_derang(n): | |
comparison = np.arange(n) | |
sigma = np.random.permutation(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
import statistics | |
import random | |
import numpy as np | |
import time | |
def repeated_cull_sim(initial_size, runs): | |
sum = 0 | |
init_time = time.time() |