Skip to content

Instantly share code, notes, and snippets.

View avdotion's full-sized avatar
🚩
Available in t.me/avdotion

Danila Avdoshin avdotion

🚩
Available in t.me/avdotion
  • Moscow, Russia
View GitHub Profile
@avdotion
avdotion / binary_heap.py
Created August 29, 2017 15:38
Binary Heap
# Структура данных "Двоичная куча (Binary Heap)"
# https://habrahabr.ru/post/112222/
class Heap:
def __init__(self, data=[]):
# Функция построение кучи O(N)
self.data = data
for i in range(len(self.data) // 2, -1, -1):
self.heapify(i)
@avdotion
avdotion / bot.py
Last active December 3, 2017 11:10
Общажный бот (Telegram Bot)
import telebot
import datetime
import random
import time
token = ''
bot = telebot.TeleBot(token)
# Идентификаторы чатов, для которых разрешен доступ
ACCESS_CHAT_ID = {-1001093224903, 126491903}
@avdotion
avdotion / number.py
Created February 20, 2018 15:11
Перевод из одной системы счисления в другую
class Number:
def __init__(self, value, base):
'''Конструктор класса'''
# Проверка на тип
# Класс основан на работе со списком значений (цифр числа)
# На этом шаге ~любой тип преобразуется в список строк
if isinstance(value, type(1)):
self.value = list(str(value))
elif isinstance(value, type([])):
self.value = value
@avdotion
avdotion / keys.py
Last active February 27, 2018 19:49
Решения задач ЕГЭ (27) c сайта К. Полякова (http://kpolyakov.spb.ru)
# -*- coding: utf-8 -*-
# Демонстрация альтернативных способов решения задач ЕГЭ (27) на языке Python 3
# с сайта К. Полякова. Исправления и рекомендации приветствуются!
"""
-------------------------------------------------
Задача C4-70.
Решение на языке Python 3.
-------------------------------------------------
@avdotion
avdotion / styles.less
Last active June 26, 2018 17:25
Atom Settings for Operator Mono and Fira Code fonts
// Fira Code (Free)
// https://github.com/tonsky/FiraCode
// Operator Fonts (Paid)
// https://www.typography.com/fonts/operator/overview/
// you can manually enable/disable my styles by colors
//
// add next lines to your atom stylesheet
@avdotion
avdotion / cell.js
Last active June 11, 2018 14:29
Maze generation algorithm (Recursive backtracker) (p5.js)
class Cell {
constructor(i, j) {
this.i = i;
this.j = j;
this.walls = {
top: true,
right: true,
bottom: true,
left: true,
}
@avdotion
avdotion / sketch.js
Created June 11, 2018 14:29
Fractal Trees - Recursive (p5.js)
const maxRecurtionDepth = 15;
let slider, angle;
const len = 200;
function setup() {
createCanvas(600, 600);
slider = createSlider(0, PI, PI/4, PI/16);
}
@avdotion
avdotion / arch-intallation-instruction.md
Last active August 29, 2018 08:32
Arch installation commands

Arch Installation Yokel Guide

Pay attention to zsh and swapfile

Setup the network

sudo wifi-menu

Update the Pacman database

pacman -Syyy

@avdotion
avdotion / source.py
Created July 17, 2018 11:17
Reading Coefs in Polynom (str to dict)
class Polynom:
def __init__(self, s):
self.coefs = self.reborn(s)
def reborn(self, source):
result = list()
coefs = dict()
source = source.split('+')
@avdotion
avdotion / flashbox.js
Created July 27, 2018 22:17
Implementations (Stack, List, Queue)
/**
* Stack implementation
* https://www.wikiwand.com/en/Stack_(abstract_data_type)
*/
export class Stack {
/**
* array implementation
* without shift (trying to be O(1) for adding and deleting)
* @param {Number} [maxsize=-1] [maxsize may be equal to -1 for dynamic]
*/