This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a solution of week 1 for the Bitcoin and Cryptocurrency Technologies course (scrooge coin) | |
* https://www.coursera.org/learn/cryptocurrency | |
* Please, try yourself before looking this code | |
* I was able to get 100/100 score! | |
*/ | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from tqdm import tqdm | |
import math | |
W, H = 200, 200 # размеры картинки | |
ITER = 255 | |
FRAMES = 100 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def run(code, mem_size=256): | |
# 1. этап составим карту скобок | |
# ключ и значения - индекс байта в коде | |
# по любой скобке находим ей пару | |
bracket_map = {} | |
stack = [] | |
for pos, symbol in enumerate(code): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
day | infected | dead | |
---|---|---|---|
20.01.2020 | 278 | 4 | |
21.01.2020 | 326 | 6 | |
22.01.2020 | 547 | 8 | |
23.01.2020 | 639 | 14 | |
24.01.2020 | 916 | 25 | |
25.01.2020 | 2000 | 40 | |
26.01.2020 | 2700 | 57 | |
27.01.2020 | 4400 | 64 | |
28.01.2020 | 5970 | 87 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# метакласс наследуется от Type | |
class Final(type): | |
def __new__(mcls, name, bases, attrs): | |
""" | |
:param name: Имя нового класса | |
:param bases: Список его базовых классов | |
:param attrs: Набор атрибутов класса | |
:return: новый класс | |
""" | |
for base in bases: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
from datetime import datetime, timedelta | |
import sys | |
import os | |
def git_commit_ago(days, message): | |
date = datetime.now() - timedelta(days=days) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copyright https://t.me/pyway | |
from functools import wraps | |
class Repeater: | |
def __init__(self, n): | |
self.n = n | |
def __call__(self, f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
for _ in range(self.n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copyright https://t.me/pyway | |
import time | |
# это вспомогательный декоратор будет декорировать каждый метод класса, см. ниже | |
def timeit(method): | |
def timed(*args, **kw): | |
ts = time.time() | |
result = method(*args, **kw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import tee | |
def source(): | |
for i in range(5): | |
print(f'next is {i}') | |
yield i | |