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 dataclasses import dataclass | |
from typing import List | |
@dataclass | |
class Mapping: | |
destination_range_start: int | |
source_range_start: int | |
range_length: int | |
def is_input_in_range(self, input_num) -> bool: |
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 collections import defaultdict | |
from dataclasses import dataclass | |
from typing import List, Set | |
@dataclass | |
class Deck: | |
id: int | |
winning: Set[int] | |
mine: Set[int] |
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
@dataclass | |
class Deck: | |
id: int | |
winning: Set[int] | |
mine: Set[int] | |
def count_point(self) -> int: | |
mine_winning = self.winning.intersection(self.mine) | |
num_of_match = len(mine_winning) | |
if num_of_match <= 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
@dataclass | |
class PartNumber: | |
id: int | |
value: int | |
def __hash__(self): | |
return self.id | |
_part_number_id = 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
from dataclasses import dataclass | |
from typing import Dict, Set | |
@dataclass | |
class PartNumber: | |
id: int | |
value: int | |
def __hash__(self): |
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
@dataclass | |
class GameSet: | |
red: int = 0 | |
green: int = 0 | |
blue: int = 0 | |
def match_rule(self, rule: 'GameSet'): | |
if any([ | |
self.blue > rule.blue, |
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
# https://adventofcode.com/2023/day/1 | |
# get full input at https://adventofcode.com/2023/day/1/input | |
if __name__ == '__main__': | |
per_line = _input.split('\n') | |
total = 0 | |
for line in per_line: | |
print(f'line: {line}') |
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 collect_cases(stack, test_case_num): | |
if test_case_num <= 0: | |
return | |
num_of_inputs = input() | |
actual_input = input() | |
stack.append((num_of_inputs, actual_input)) | |
collect_cases(stack, test_case_num - 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
import ast | |
import os | |
from random import randrange | |
from graphviz import Digraph | |
def random_color(): | |
r = randrange(255) | |
g = randrange(start=0, stop=10) |
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
package caskdb | |
import ( | |
"github.com/cornelk/hashmap" | |
"math" | |
"sync" | |
"testing" | |
) | |
type m struct { |
NewerOlder