-
Notifications
You must be signed in to change notification settings - Fork 50
Б12-514, Баринов Михаил #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e16f878
5282b68
aef1f61
748c4af
e824447
cda65a2
74bc77c
609cf93
1c98979
87a358a
519a468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| from random import uniform | ||
| from time import sleep | ||
| from typing import ( | ||
| Callable, | ||
| ParamSpec, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1 @@ | ||
| def get_amount_of_ways_to_climb(stair_amount: int) -> int: | ||
| step_prev, step_curr = 1, 1 | ||
| # ваш код | ||
| return step_curr | ||
| def get_amount_of_ways_to_climb(stair_amount: int) -> int: ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def flip_bits_in_range(num: int, left_bit: int, right_bit: int) -> int: | ||
| # ваш код | ||
| return num | ||
| return num |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def get_cube_root(n: float, eps: float) -> float: | ||
| # ваш код | ||
| return n | ||
| return n |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def is_arithmetic_progression(lst: list[list[int]]) -> bool: | ||
| # ваш код | ||
| return False | ||
| return False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def merge_intervals(intervals: list[list[int, int]]) -> list[list[int, int]]: | ||
| # ваш код | ||
| return [[0,0]] | ||
| return [[0, 0]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def move_zeros_to_end(nums: list[int]) -> list[int]: | ||
| # ваш код | ||
| return 0 | ||
| return 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def find_row_with_most_ones(matrix: list[list[int]]) -> int: | ||
| # ваш код | ||
| return 0 | ||
| return 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def count_cycles(arr: list[int]) -> int: | ||
| def count_cycles(arr: list[int]) -> int: | ||
| # ваш код | ||
| return 0 | ||
| return 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def is_palindrome(text: str) -> bool: | ||
| # ваш код | ||
| return False | ||
| return False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def are_anagrams(word1: str, word2: str) -> bool: | ||
| # ваш код | ||
| return False | ||
| return False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def unzip(compress_text: str) -> str: | ||
| # ваш код | ||
| return compress_text | ||
| return compress_text |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def reg_validator(reg_expr: str, text: str) -> bool: | ||
| def reg_validator(reg_expr: str, text: str) -> bool: | ||
| # ваш код | ||
| return False | ||
| return False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def simplify_path(path: str) -> str: | ||
| # ваш код | ||
| return path | ||
| return path |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def int_to_roman(num: int) -> str: | ||
| # ваш код | ||
| return "" | ||
| return "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def get_len_of_longest_substring(text: str) -> int: | ||
| # ваш код | ||
| return 0 | ||
| return 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,5 @@ def is_there_any_good_subarray( | |
| nums: list[int], | ||
| k: int, | ||
| ) -> bool: | ||
|
|
||
| # ваш код | ||
| return False | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| def count_unique_words(text: str) -> int: | ||
| # ваш код | ||
| return 0 | ||
| return 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from typing import Callable | ||
|
|
||
|
|
||
| def make_averager(accumulation_period: int) -> Callable[[float], float]: | ||
| # ваш код | ||
| pass | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| import sys | ||
|
|
||
|
|
||
| class FileOut: | ||
| def __init__( | ||
| self, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,23 @@ def get_dominant_color_info( | |
| image: np.ndarray[np.uint8], | ||
| threshold: int = 5, | ||
| ) -> tuple[np.uint8, float]: | ||
| # ваш код | ||
| if threshold < 1: | ||
| raise ValueError("threshold must be positive") | ||
|
|
||
| return 0, 0 | ||
| pixels = image.flatten() | ||
| counts = np.zeros(256) | ||
| for color in range(256): | ||
| counts[color] = np.sum(pixels == color) | ||
|
|
||
| result_color, result_count = 0, 0 | ||
| for color in range(256): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше было бы 256 вынести в константу, чтобы было сразу понятно, что вы имеете ввиду количество цветов, и еще вы далее используете 255, что является производной от этого числа |
||
| if counts[color] == 0: | ||
| continue | ||
| min_with_threshold = max(0, color - (threshold - 1)) | ||
| max_with_threshold = min(255, color + (threshold - 1)) | ||
| count = np.sum(counts[min_with_threshold : max_with_threshold + 1]) | ||
| if count > result_count: | ||
| result_count = count | ||
| result_color = color | ||
|
|
||
| return np.uint8(result_color), result_count / pixels.size * 100 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,14 @@ class ShapeMismatchError(Exception): | |
| def get_projections_components( | ||
| matrix: np.ndarray, | ||
| vector: np.ndarray, | ||
| ) -> tuple[np.ndarray | None, np.ndarray | None]: ... | ||
| ) -> tuple[np.ndarray | None, np.ndarray | None]: | ||
| if matrix.shape[0] != matrix.shape[1] or matrix.shape[0] != vector.shape[0]: | ||
| raise ShapeMismatchError | ||
|
|
||
| if np.linalg.det(matrix) == 0: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Во-первых, как вы можете помнить из первого семестра, делать == между 2 числами float - это неправильно. |
||
| return None, None | ||
|
|
||
| scalar_result = matrix @ vector | ||
| lengths = np.sum(matrix**2, axis=1) | ||
| projections = (scalar_result / lengths)[:, np.newaxis] * matrix | ||
| return projections, vector - projections | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть np.unique, которая быстрее