Skip to content

Instantly share code, notes, and snippets.

View OlegZero13's full-sized avatar
🎯
Focusing

Oleg Żero OlegZero13

🎯
Focusing
View GitHub Profile
# 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:
@OlegZero13
OlegZero13 / nppoly.py
Last active July 15, 2020 22:06
Symbolic implementation of a polynomial using numpy and bare python.
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)
@OlegZero13
OlegZero13 / zombie-survival.py
Created February 3, 2020 00:28
Random search algorithm explained
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
@OlegZero13
OlegZero13 / quaternion.py
Last active November 8, 2019 06:21
Model of a quaternion
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