Skip to content

Instantly share code, notes, and snippets.

View kupp1's full-sized avatar
🎓
ITMO

Dmitrii Kupershtein kupp1

🎓
ITMO
View GitHub Profile
@kupp1
kupp1 / main.py
Created September 23, 2019 13:23
calculate expected value & standard deviation of sequence of numbers
import math
values = {}
N = 0
while True:
inpt = input()
if inpt == 'stop':
break
N += 1
inpt = float(inpt)
@kupp1
kupp1 / solve.c
Created July 29, 2019 10:00
Capacity & multiplicity
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char *argv[])
{
uint_fast16_t N, count = 0;
scanf("%" SCNuFAST16, &N);
uint_fast16_t cur_cap = 1, following = 10;
/* cur_cap - текущая разрядность числа
following - первое число большей разрядности */
@kupp1
kupp1 / Makefile
Created July 10, 2019 12:31
Makefile for Love2d projects (make dist for windows and linux)
game=test
love_win=./.love_win
love_linux=./.love_linux
$(game): clean dirs love linux windows
.PHONY: clean dirs
clean:
-rm -r build
dirs:
@kupp1
kupp1 / vgnr.py
Created July 5, 2019 17:24
Vigenere cipher
def vigenere(msg, key, crypt_flag=True):
"""
vigenere cipher for small latin letters
crypt_flag == True mean crypt
crypt_flag == False mean decrypt
"""
msg, key = list(map(ord, msg)), list(map(ord, key))
msglen, keylen = len(msg), len(key)
new_msg = ''
for i in range(msglen):
Aachener Printen
Abernethy
Acıbadem kurabiyesi
Afghan biscuits
Alfajor
Almond biscuit
Amaretti di Saronno
Animal cracker
ANZAC biscuit
Aparon
#include <stdio.h>
#include <inttypes.h>
#define N 100000
uint_fast16_t f()
{
static uint_fast16_t last = 0, indxs[N] = {0}, i = 0;
i++;
uint_fast16_t tmp = last;
@kupp1
kupp1 / s_eq.py
Last active June 10, 2019 19:58
Python hls histogram equalization
import sys
from PIL import Image
import numpy as np
import colorsys as cs
im = Image.open(sys.argv[1]).convert('RGB')
rgb_array = np.array(im)
shape = rgb_array.shape
@kupp1
kupp1 / hist.py
Last active June 10, 2019 20:06
Python pretty image histogram with cdf
import numpy
import sys
from PIL import Image
import matplotlib.pyplot as plt
def get_rgb(r: int, g: int, b: int):
if 0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255:
return '#%02x%02x%02x' % (r, g, b)
@kupp1
kupp1 / Makefile
Last active June 10, 2019 11:57
Monty Hall problem with gnuplot
P=monty
OBJECTS=
CFLAGS = -g -Iinclude -Wall `pkg-config --cflags libsodium`
LDLIBS= `pkg-config --libs libsodium`
CC=cc
$(P): $(OBJECTS)
clean:
-rm $(OBJECTS) $(P)
@kupp1
kupp1 / sorts_n2.py
Created April 4, 2019 19:07
Python Sorts
import random
def selection_sort(a: list):
length = len(a)
for i in range(length):
current_min_i = i
current_min = a[i]
for j in range(i + 1, length):
if a[j] < current_min:
current_min = a[j]