This file contains hidden or 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
| frequencies:dict = { | |
| "E": "12.02", | |
| "T": "9.1", | |
| "A": "8.12", | |
| "O": "7.68", | |
| "I": "7.31", | |
| "N": "6.95", | |
| "S": "6.28", | |
| "R": "6.02", | |
| "H": "5.92", |
This file contains hidden or 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 enum import Enum | |
| from typing import NamedTuple | |
| from more_itertools import chunked | |
| class Result(Enum): | |
| NOTPRESENT = 1 | |
| INCORRECT_LOCATION = 2 | |
| CORRECT_LOCATION = 3 |
This file contains hidden or 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 functools import lru_cache | |
| from math import floor, ceil | |
| from statistics import mean, median | |
| def sum_c(pop: list[int], centroid: int) -> int: | |
| @lru_cache | |
| def gauss_sum(n: int) -> int: | |
| return (n * (n + 1)) // 2 |
This file contains hidden or 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 itertools import chain | |
| from more_itertools import chunked | |
| def transpose_rows_to_columns(rows) -> list: | |
| return [list(i) for i in zip(*rows)] | |
| def get_data(fn): | |
| numbers, *boards = open(fn).read().split('\n\n') |
This file contains hidden or 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 get_data(fn): | |
| data: list = [] | |
| with open(fn) as f: | |
| for line in f: | |
| direction, distance = line.rstrip().split() | |
| data.append((direction, int(distance))) | |
| return data | |
| class Submarine: |
This file contains hidden or 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 more_itertools | |
| def get_data(filename: str) -> list: | |
| with open(filename, 'r') as f: | |
| return [int(line.rstrip('\n')) for line in f] | |
| def make_couples(singles: list) -> list: | |
| return zip(singles, singles[1:]) |
This file contains hidden or 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 random | |
| from collections import Counter | |
| from enum import Enum, IntEnum, unique | |
| @unique | |
| class Outcome(Enum): | |
| COMPUTER = 2 | |
| TIED = 0 | |
| PLAYER = 1 |
This file contains hidden or 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 random | |
| from typing import NamedTuple | |
| class Card(NamedTuple): | |
| suit: str | |
| face: str | |
| face_value: int | |
| @property | |
| def description(self): |
This file contains hidden or 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 typing import NamedTuple, List | |
| class Chemical_Structure(NamedTuple): | |
| name: str | |
| synonyms: List[str] | |
| iupac_name: str | |
| pubchem_cid: str | |
| inchi: str | |
| inchi_key: str |
This file contains hidden or 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
| """A package for Morse encoding and decoding.""" | |
| from collections import UserDict | |
| from time import sleep | |
| from typing import NamedTuple | |
| from pysinewave import SineWave | |
| class MorseDict(UserDict): | |
| def __init__(self, dictionary=None): |
NewerOlder