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
# fragment 1 | |
def mandelbrot_iter(resolution=10): | |
X = np.linspace(-2.0, 1.0, num=resolution) | |
Y = np.linspace(-1.0, 1.0, num=resolution) | |
C = X.reshape(len(X), 1) + 1j * Y.reshape(1, len(Y)) | |
Z = np.zeros_like(C) | |
P = np.zeros_like(Z, dtype=int) | |
while True: |
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 numpy as np | |
from functools import reduce, lru_cache | |
@lru_cache(maxsize=None) | |
def binom(n, k): | |
if k == 0: return 1 | |
if n == k: return 1 | |
return binom(n - 1, k - 1) + binom(n - 1, k) |
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 random | |
E = 30 # expiry of anti-zombie serum | |
X = 10 # initial ammo supply | |
class Survival: | |
def __init__(self, total_days, pods, supplies_init=[E]*X): | |
self.total_days = total_days |
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
from math import sin, cos, atan2, asin, sqrt | |
class Quaternion: | |
def __init__(self, w, x, y, z): | |
self.w = w | |
self.x = x | |
self.y = y | |
self.z = z | |
@classmethod |