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
<?php | |
namespace Acme\DemoBundle\DependencyInjection\Compiler; | |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\DependencyInjection\Reference; | |
class DoctrineEntityListenerPass implements CompilerPassInterface | |
{ |
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
module.exports = (function () { | |
var prev = function (x) { | |
return x & (x - 1); | |
}, next = function (x) { | |
return (x | (x - 1)) + 1; | |
}, Summator = function (length) { | |
if (1 > length) { | |
throw { | |
message: 'Length is too small', | |
}; |
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/bin/env php | |
<?php | |
$jobs = new \SplQueue(); | |
$workers = (int) `nproc`; | |
for ($i = 0; $i < 5 * $workers; ++$i) { | |
$jobs->enqueue(rand(100, 500)); | |
} | |
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/bin/env python3 | |
from typing import List, Tuple | |
LEFT_RIGHT_DIRECTIONS = tuple(range(-1, 2)) | |
CENTRAL_DIRECTIONS = tuple(i for i in range(-1, 2) if i != 0) | |
with open("input.txt", "r") as f: | |
matrix = [line.strip() for line in f] |
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/bin/env python3 | |
from typing import Set | |
def str_to_set(numbers: str) -> Set[int]: | |
return set(int(x) for x in numbers.strip().split(" ") if x) | |
ans = 0 |
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/bin/env python3 | |
with open("input.txt") as f: | |
seeds = [int(x) for x in f.readline().strip().split(':')[1].split(' ') if x] | |
f.readline() | |
steps = [] |
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/bin/env python3 | |
from collections import Counter | |
from enum import IntEnum | |
from typing import Mapping, Tuple | |
CARDS: Tuple[str, ...] = ('J', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'Q', 'K', 'A', ) | |
CARDS_VALUES: Mapping[str, int] = {c: i for i, c in enumerate(CARDS, start=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
#!/usr/bin/env python3 | |
import re | |
from itertools import cycle | |
map = {} | |
ROUTE = re.compile(r"^(\w{3}) = \((\w{3}), (\w{3})\)$") | |
index_map = { | |
'L': 0, |
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/bin/env python3 | |
def solve(arr: list[int]) -> int: | |
n = len(arr) | |
x = [arr] | |
for i in range(n - 1): | |
x.append([x[i][j + 1] - x[i][j] for j in range(n - i - 1)]) | |
x[-1].append(0) | |
for i in range(n - 2, -1, -1): | |
x[i].append(x[i][-1] + x[i + 1][-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
#!/usr/bin/env python3 | |
from typing import Mapping | |
FROM_TO_MAPPING: Mapping[tuple[int, int], Mapping[str, tuple[int, int]]] = { | |
(0, 2): { | |
'-': (0, 2), | |
'J': (-2, 0), | |
'7': (2, 0), |
OlderNewer