Skip to content

Instantly share code, notes, and snippets.

View mesiriak's full-sized avatar
🏀
\\

Max mesiriak

🏀
\\
  • treeum
  • Lutsk, Ukraine
  • 04:28 (UTC +03:00)
  • X @mesirisk
View GitHub Profile
import random
from math import pow
a = random.randint(2, 10)
def gcd(a, b):
if a < b:
return gcd(b, a)
elif a % b == 0:
return b;
@mesiriak
mesiriak / rsa-mini.py
Last active August 15, 2021 16:43
so, i tried to do it. Hope in future it'll be easier to do cryptographic alghorithms
def GCD(a,b):
g = [max(a,b),min(a,b)]
mass = [[max(a,b),min(a,b)]]
while g[0] != 0 and g[1] != 0:
g[0], g[1] = g[1], g[0] % g[1]
mass.append([g[0],g[1]])
return mass, g[0]
def euclid_ext(a, b):
if b == 0:
@mesiriak
mesiriak / path-finder-4-4kyu.py
Last active April 16, 2021 09:38
Codewars. Python
import re
def check(exp):
if len(exp) == 1 and exp[0] in ["r","l","R","L"]:
return f"{exp}0"
else:
return exp
def mutation(vector,y,x,val):
if vector == "right": x+= val
import collections
import re
def top_3_words(text):
c = collections.Counter(re.findall(r"[a-z']*[a-z]+[a-z']*", text.lower()))
return [i[0] for i in c.most_common(3)]
from math import factorial
def expand(expr):
print(expr)
expr = expr.split("^") # Splitting expression
expr[0] = expr[0][1:-1:1]
m = list(expr[0])
m.reverse()
sign = ""
using System;
using System.Numerics;
public static class Kata
{
public static string sumStrings(string a, string b)
{
if (BigInteger.TryParse(a, out _) == false || BigInteger.TryParse(b, out _) == false ){return "5";}
return (BigInteger.Parse(a)+BigInteger.Parse(b)).ToString();
}
from numpy import*;circleIntersection=lambda a,b,r:r*r*(lambda q:q<1and arccos(q)-q*(1-q*q)**.5)(hypot(*subtract(b,a))/r/2)//.5
@mesiriak
mesiriak / make-a-spiral-3kyu.py
Created April 15, 2021 13:55
Codewars. Python
def spiralize(w):
arr = [[0 for _ in range(w)] for _ in range(w)]
for i in range(w):
arr[0][i] = 1
x,y = w-1,1
k = w-1
arrow = (-1,1)
while k>0:
for i in range(k):
arr[y+arrow[1]*i][x] = 1
@mesiriak
mesiriak / path-finder-2-4kyu.py
Last active April 16, 2021 09:39
Codewars. Python
def path_finder(maze):
res = list(map(list,maze.split()))
res[0][0] = 0
moves = [(0,0)]
for move in moves:
y,x = move
if y+1 < len(res) and res[y+1][x] == ".":
res[y+1][x] = res[y][x] + 1
moves.append((y+1,x))
if y+1 == len(res)-1 and x == len(res)-1:
@mesiriak
mesiriak / path-finder-1-4kyu.py
Last active April 16, 2021 09:39
Codewars. Python
def path_finder(maze):
res = list(map(list,maze.split()))
res[0][0] = 0
wasd = ""
a = 0
moves = [(0,0)]
for move in moves:
y,x = move
if y+1 < len(res) and res[y+1][x] == ".":
res[y+1][x] = res[y][x] + 1