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
def _bm_pred_compil(x): | |
d = {} | |
lenX = len(x) | |
for i in range(len(x)): | |
# сколько символов с правого края до этой буквы | |
d[ord(x[i])] = lenX - i | |
return d | |
def bms(s, x): | |
d = _bm_pred_compil(x) |
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
def f(s1, s2): | |
if not s1 or not s2: | |
return len(s1)+len(s2) | |
elif s1[-1]==s2[-1]: | |
return f(s1[:-1], s2[:-1]) | |
else: | |
#вставка/удаление | |
a = min(f(s1[:-1], s2), f(s1, s2[:-1])) | |
#замена |
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
def f(s1, s2): | |
if not s1 or not s2: | |
return '' | |
elif s1[-1]==s2[-1]: | |
return f(s1[:-1], s2[:-1]) + s2[-1] | |
else: | |
return max((f(s1[:-1],s2), f(s1, s2[:-1])), key=len) | |
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 grab import Grab, GrabError | |
from time import time | |
g = Grab() | |
t = time() | |
g.go('ip.appspot.com') | |
print(time()-t) | |
print(g.response.body) | |
g.setup(reuse_cookies=False, proxy_type='socks4', connect_timeout=5, timeout=5, proxy="127.0.0.1:9050"); |
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 __future__ import annotations | |
from typing import Generic, TypeVar | |
T = TypeVar("T") | |
# ABC | |
class DatabaseProvider: |
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
{ | |
"ab": "I, me", | |
"abaq": "myself", | |
"abaqe": "my own", | |
"abaqz": "ourselves", | |
"abz": "we, us", | |
"abze": "our", | |
"ac": "thou, you", | |
"acaz": "ye", | |
"acaze": "your", |
OlderNewer