Skip to content

Instantly share code, notes, and snippets.

apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.sabal.helloopencv"
minSdkVersion 15
targetSdkVersion 19
@sabal202
sabal202 / insertion_sort.py
Created December 20, 2017 10:56
insertion_sort created by sabal - https://repl.it/@sabal/insertionsort
def insertion_sort(arr, reversed=False):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
if reversed:
while j >= 0 and arr[j] < key:
arr[j + 1] = arr[j]
j -= 1
else:
while j >= 0 and arr[j] > key:
import re
n = int(input())
num = re.compile("[-0-9]+")
states = dict()
for i in range(n):
line = input().rstrip().replace("<", " ").split()
print(line)
if len(line) == 0:
@sabal202
sabal202 / sol.cpp
Last active January 12, 2018 17:32
#include <iostream>
#include <algorithm>
using namespace std;
#define forn(i, n) for(int i = 0; i < (n); ++i)
typedef pair<long long, long long> pt;
#define x first
#define y second
N = int(input()) + 1
A = [True]*(N)
for k in range(2, N):
if A[k]:
print(k, end=" ")
for i in range(k*k, N, k):
A[i] = False
@sabal202
sabal202 / Simples.py
Created January 21, 2018 04:54
Simples created by sabal - https://repl.it/@sabal/Simples
#
def s(n):
m = 0
while n > 0:
m += n % 10
n //= 10
return m
def l(n):
m = 0
from math import ceil, sqrt
class FuncCounter:
"""Класс-обертка для функции, который выглядит как функция
Метод __call__ вызывается, когда вызываешь экземпляр обертки как ф-ю
Класс хранит все вызовы функции и их результаты в словаре self.calls
В атрибуте counter хранится количество уникальных вызовов функции func
"""
@sabal202
sabal202 / Rangoli.py
Last active October 2, 2019 19:09
Rangoli is a form of Indian folk art based on creation of patterns.
def print_rangoli(size):
from string import ascii_lowercase
alph = ascii_lowercase[:size]
main_line = alph[::-1] + alph[1:]
for i in list(range(1, size)) + list(range(size, 0, -1)):
s = main_line[:i] + main_line[2 * size - i:]
print('{x:-^{size}}'.format(x='-'.join(s), size=n))
def designer_door_mat(n, m):
f = '.|.'
w = "WELCOME"
for i in range(1, n - 1, 2):
print("{x:-^{size}}".format(x=f * i, size=m))
print("{x:-^{size}}".format(x=w, size=m))
for i in range(n - 2, 0, -2):
print("{x:-^{size}}".format(x=f * i, size=m))
@sabal202
sabal202 / minion_game.py
Created September 18, 2019 19:44
Kevin and Stuart want to play the 'The Minion Game'.
def minion_game(string):
s = string
n = len(s)
stuart = kevin = 0
for i in range(n):
if s[i] in 'AEIOU':
kevin += n - i
else:
stuart += n - i
if kevin == stuart: