Skip to content

Instantly share code, notes, and snippets.

View erikseulean's full-sized avatar
🐻

Erik-Cristian S. erikseulean

🐻
  • London
View GitHub Profile
def keyboard_path(word):
path = []
current = 'a'
for letter in word:
x,y = get_position(current)
nx, ny = get_position(letter)
path += math.abs(nx - x) * ['down' if nx > x else 'up']
path += math.abs(ny - y) * ['right' if ny > y else 'left']
'''
compute the minimum number of removals in order to make the string palindrome
'''
def palindromic_substring(word):
dp = [[-1 for _ in range(len(word) + 1)] for _ in range(len(word)+1)]
def count_nr_chars(word, i, j, count):
if dp[i][j] != -1:
'''
given a final score in a certain sport, get all the possible scores during
the game. the scoring points are given ahead
'''
from copy import copy
def get_scores(points, result):
dp = [0 for _ in range(result + 1)]
dp[0] = 1
@erikseulean
erikseulean / shortest_substring.py
Created February 5, 2018 17:35
Shortest substring containing all
def shortest_substring(words, text):
total, start, mstart, mend = 0, 0, 0, 0
min_value = len(text)
counts = defaultdict(int)
for i in range(len(text)):
if text[i] in words:
counts[text[i]] = counts[text[i]] + 1
if counts[text[i]] == 1:
total = total + 1
async def scrap_exchanges():
coins = pd.DataFrame.from_csv('crypto/data/coins.csv')
data = defaultdict(lambda:[])
chunks = [coins[i: i + 5] for i in range(0, len(coins), 5)]
for chunk in chunks[0:10]:
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
futures = [loop.run_in_executor(executor, get_exchanges_for_coin, coin.split(":")[0]) for coin in chunk["Coins"]]