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 relindex_value(iterable: list, column: list) -> list[dict]: | |
result = [] | |
aux = {} | |
for index, item in enumerate(iterable): | |
aux[column[index % len(column)]] = item | |
if (index % len(column)) == (len(column) - 1): | |
result.append(aux) |
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
function space(){ | |
param($Directory) | |
$total = 0 | |
foreach($file in Get-ChildItem $Directory){ | |
$total += $file.length | |
} | |
return $total / 1Gb | |
} |
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
{ | |
"MrYiang": { | |
"tf_projectile_arrow": { | |
"kills": 2, | |
"crits": 2 | |
}, | |
"spy_cicle": { | |
"kills": 2, | |
"crits": 2 | |
}, |
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 flatten(structure: dict, head = [], flattened = {}) -> list: | |
for key, value in structure.items(): | |
if isinstance(value, dict): | |
head.append(key) | |
flatten(value, [*head, key], flattened) | |
else: | |
flattened['__'.join(head)] = value | |
return flattened |
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 parse_qs(qs: str) -> dict: | |
kvs = qs.split('&') | |
parsed = {} | |
for kv in kvs: | |
key, value = kv.split('=') | |
if key not in parsed: | |
parsed[key] = value |
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 combinations(letters: list, length: int = 4, string = '', result = []) -> list[str]: | |
if length == len(string): | |
result.append(string) | |
return | |
for letter in letters: | |
combinations(letters, length, string + letter, result) | |
return result |
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 algorithm(dataset: list, input: str, output_length: int = None) -> str: | |
matches = filter(lambda quote: input in quote, dataset) | |
processed = map(lambda quote: quote[quote.index(input):], matches) | |
return [segment[0:output_length] for segment in processed] |
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 compound(n, ceiling: int = 10, powers: list = []): | |
for i in range(2, ceiling): | |
if n % i == 0: | |
powers.append(i) | |
return compound(n // i, ceiling, powers) | |
powers.append(n) | |
return powers |
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 wrap(array, size) -> list: | |
result = [] | |
aux_array = [] | |
for i in array: | |
aux_array.append(i) | |
if len(aux_array) == size: | |
result.append(aux_array) |
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 euler() -> Decimal: | |
e = Decimal(0) | |
f = 1 | |
for n in range(2, 100_000): | |
f *= n | |
e += Decimal((1 / f)) | |
return e + 2 |
NewerOlder