Skip to content

Instantly share code, notes, and snippets.

View mesiriak's full-sized avatar
🏀
\\

Max mesiriak

🏀
\\
  • treeum
  • Lutsk, Ukraine
  • 17:40 (UTC +03:00)
  • X @mesirisk
View GitHub Profile
def format_duration(start_number):
print(start_number)
_seconds = start_number % 60
_minutes = start_number // 60 % 60
_hours = start_number % (3600*24) // 3600
_days = start_number % (3600*24*365) // (3600*24)
_years = start_number // (3600*24*365)
mass_of_results = []
using System;
using System.Linq;
public class PyramidSlideDown
{
public static int LongestSlideDown(int[][] pyramid)
{
for (int i = 1; i < pyramid.Length; i++)
for (int j = 0; j < pyramid[i].Length; j++)
if (j == 0) { pyramid[i][j] += pyramid[i - 1][j]; }
@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
@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 / 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
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
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 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 = ""
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)]
@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