Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
71df33b
Solution Task 1
Glekmofob Sep 20, 2025
346f3cd
Homework for 27.09.2025
Glekmofob Sep 24, 2025
387781f
Commented task 3
Glekmofob Sep 24, 2025
0d6b3e4
Ruff reform Comment task 3
Glekmofob Sep 24, 2025
a515846
Homework 26.09.2025 no lists fix
Glekmofob Sep 25, 2025
1301dac
Merge pull request #1 from EvgrafovMichail/main
Glekmofob Oct 4, 2025
8981f15
Homework for 11.10.2025
Glekmofob Oct 10, 2025
eec730e
Merge pull request #2 from EvgrafovMichail/main
Glekmofob Oct 11, 2025
a0774cd
18.10.2025 HomeWork
Glekmofob Oct 17, 2025
dd48eaf
Merge pull request #3 from EvgrafovMichail/main
Glekmofob Oct 23, 2025
056e145
Homework 25.10.2025
Glekmofob Oct 23, 2025
6cc72e2
Merge pull request #4 from EvgrafovMichail/main
Glekmofob Oct 27, 2025
94b14b1
01.11.2025 Homework
Glekmofob Oct 31, 2025
b6ec447
Merge pull request #5 from EvgrafovMichail/main
Glekmofob Nov 14, 2025
fa621a3
homework:
Glekmofob Nov 14, 2025
71da387
Merge pull request #6 from EvgrafovMichail/main
Glekmofob Nov 24, 2025
0de0dc9
Hw1 done
Glekmofob Nov 29, 2025
8597d63
Hw1 done
Glekmofob Nov 29, 2025
a7218e7
Hw1 done
Glekmofob Nov 29, 2025
80aa490
Merge pull request #7 from EvgrafovMichail/main
Glekmofob Dec 3, 2025
b3c0231
Vec2D Done
Glekmofob Dec 6, 2025
3a812f4
Vec2D Done
Glekmofob Dec 6, 2025
850a204
Vec2D Done
Glekmofob Dec 6, 2025
9a7fcd0
Merge pull request #8 from EvgrafovMichail/main
Glekmofob Dec 12, 2025
5cebb1c
Hw done
Glekmofob Dec 12, 2025
5452ce5
forgor ruff check
Glekmofob Dec 12, 2025
8999f59
somekindofbs
Glekmofob Mar 4, 2026
0471087
Merge branch 'main' of github.com:EvgrafovMichail/python_mipt_dafe_ta…
Glekmofob Mar 4, 2026
c921a7d
Merge branch 'EvgrafovMichail-main'
Glekmofob Mar 4, 2026
07b68a4
Homework for 06.03.2026
Glekmofob Mar 6, 2026
6d258f4
fixed solutions to not include functions that were not explained
Glekmofob Mar 10, 2026
283842f
Merge pull request #12 from EvgrafovMichail/main
Glekmofob Mar 10, 2026
136ceb4
Homework for 14.03.2026
Glekmofob Mar 12, 2026
5f6a8f2
Merge pull request #13 from EvgrafovMichail/main
Glekmofob Mar 18, 2026
d697920
Homework for 21.03.2026
Glekmofob Mar 19, 2026
eac663d
Merge branch 'main' of github.com:EvgrafovMichail/python_mipt_dafe_tasks
Glekmofob Apr 9, 2026
52c37f5
Hw for 11.04.2026
Glekmofob Apr 10, 2026
cc4534c
Forgor formating
Glekmofob Apr 10, 2026
f5cd856
Merge pull request #15 from EvgrafovMichail/main
Glekmofob Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
1,616 changes: 1,616 additions & 0 deletions .github/workflows/trying.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__

# Python Files
*solved.ipynb
.github\workflows\trying.ipynb.github\workflows\trying.ipynb
4 changes: 4 additions & 0 deletions conditions/sem01/lesson05/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

Ваша задача — определить, является ли заданная строка палиндромом.

<<<<<<< HEAD:conditions/lesson05/tasks.md
Допишите код в файле [task1](https://github.com/EvgrafovMichail/python_mipt_dafe_tasks/blob/main/solutions/lesson05/task1.py)
=======
Допишите код в файле [task1](https://github.com/EvgrafovMichail/python_mipt_dafe_tasks/blob/main/solutions/sem01/lesson05/task1.py).
>>>>>>> 7ba22f9a471a0b84a580183fed2466942f0104d2:conditions/sem01/lesson05/tasks.md

**Входные данные:**
- `text` — строка, состоящая из букв английского алфавита в верхнем и нижнем регистре длиной от 0 до 1000.
Expand Down
2 changes: 1 addition & 1 deletion conditions/sem01/lesson11/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
```

- При использовании объекта типа `Vector2D` в качестве аргумента функции `print()` в консоль должна печататься строка, представляющая собой команду создания данного объекта. Пример:
```python
```pythonV
vector = Vector2D(1, 3)
print(vector)
# Vector2D(abscissa=1, ordinate=3)
Expand Down
16 changes: 8 additions & 8 deletions deprecated_tests/sem01/tests/test_lesson02_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
0,
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_get_factorial(num: int, result_expected: int) -> None:


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
0,
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_get_doubled_factorial(num: int, result_expected: int) -> None:


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
1,
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_get_amount_of_ways_to_climb(


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
1,
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_get_multiplications_amount(


@pytest.mark.parametrize(
"num1, num2, result_expected",
"num1, num2, result_expected",
(
pytest.param(
1,
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_get_gcd(


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
1,
Expand Down Expand Up @@ -273,10 +273,10 @@ def test_get_sum_of_prime_divisors(num: int, result_expected: int) -> None:


@pytest.mark.parametrize(
"num, result_expected",
"num, result_expected",
(
pytest.param(
-10**10,
-(10**10),
False,
id="negative-ten-billion",
),
Expand Down
215 changes: 104 additions & 111 deletions deprecated_tests/sem01/tests/test_lesson04_tasks.py
Original file line number Diff line number Diff line change
@@ -1,159 +1,152 @@
import pytest
import random

import pytest

from solutions.sem01.lesson04.task1 import is_arithmetic_progression
from solutions.sem01.lesson04.task2 import merge_intervals
from solutions.sem01.lesson04.task3 import find_single_number
from solutions.sem01.lesson04.task4 import move_zeros_to_end
from solutions.sem01.lesson04.task5 import find_row_with_most_ones
from solutions.sem01.lesson04.task6 import count_cycles

@pytest.mark.parametrize("lst, expected", [
pytest.param([], True, id="empty_list"),
pytest.param([5], True, id="single_element"),
pytest.param([1, 3], True, id="two_elements"),
pytest.param([3, 1], True, id="two_elements_unsorted"),
pytest.param([1, 3, 5, 7], True, id="already_sorted_ap"),
pytest.param([3, 1, 5, 7], True, id="unsorted_ap"),
pytest.param([1, 2, 4], False, id="not_ap"),
pytest.param([10, 5, 0, -5], True, id="negative_difference"),
pytest.param([1, 1, 1, 1], True, id="constant_sequence"),
pytest.param([1, 2, 3, 5], False, id="almost_ap_but_not"),
pytest.param([0, 0, 1], False, id="two_same_one_different"),
pytest.param([10**5 + i*10**2 for i in range(1000)], True, id="long_list_true"),
pytest.param([10**5 + i*10**2 for i in range(999)] + [1], False, id="long_list_false"),
])

@pytest.mark.parametrize(
"lst, expected",
[
pytest.param([], True, id="empty_list"),
pytest.param([5], True, id="single_element"),
pytest.param([1, 3], True, id="two_elements"),
pytest.param([3, 1], True, id="two_elements_unsorted"),
pytest.param([1, 3, 5, 7], True, id="already_sorted_ap"),
pytest.param([3, 1, 5, 7], True, id="unsorted_ap"),
pytest.param([1, 2, 4], False, id="not_ap"),
pytest.param([10, 5, 0, -5], True, id="negative_difference"),
pytest.param([1, 1, 1, 1], True, id="constant_sequence"),
pytest.param([1, 2, 3, 5], False, id="almost_ap_but_not"),
pytest.param([0, 0, 1], False, id="two_same_one_different"),
pytest.param([10**5 + i * 10**2 for i in range(1000)], True, id="long_list_true"),
pytest.param([10**5 + i * 10**2 for i in range(999)] + [1], False, id="long_list_false"),
],
)
def test_is_arithmetic_progression_parametrized(lst, expected):
if len(lst) > 500:
random.shuffle(lst)
assert is_arithmetic_progression(lst) == expected


@pytest.mark.parametrize("intervals, expected", [
pytest.param([], [], id="empty"),
pytest.param([[1, 3]], [[1, 3]], id="single_interval"),
pytest.param([[10, 13], [1, 3], [2, 6], [8, 10], [15, 18]], [[1, 6], [8, 13], [15, 18]], id="classic_merge"),
pytest.param([[1, 4], [4, 5]], [[1, 5]], id="touching_intervals"),
pytest.param([[1, 4], [2, 3]], [[1, 4]], id="nested_interval"),
pytest.param([[5, 7], [1, 3], [15, 20], [0, 0], [2, 4], [6, 10], [0, 2]], [[0, 4], [5, 10], [15, 20]], id="unsorted_input"),
pytest.param([[1, 2], [3, 4], [5, 6]], [[1, 2], [3, 4], [5, 6]], id="no_overlap"),
pytest.param([[1, 10], [2, 3], [4, 5], [6, 7]], [[1, 10]], id="all_merged"),
])
@pytest.mark.parametrize(
"intervals, expected",
[
pytest.param([], [], id="empty"),
pytest.param([[1, 3]], [[1, 3]], id="single_interval"),
pytest.param(
[[10, 13], [1, 3], [2, 6], [8, 10], [15, 18]],
[[1, 6], [8, 13], [15, 18]],
id="classic_merge",
),
pytest.param([[1, 4], [4, 5]], [[1, 5]], id="touching_intervals"),
pytest.param([[1, 4], [2, 3]], [[1, 4]], id="nested_interval"),
pytest.param(
[[5, 7], [1, 3], [15, 20], [0, 0], [2, 4], [6, 10], [0, 2]],
[[0, 4], [5, 10], [15, 20]],
id="unsorted_input",
),
pytest.param([[1, 2], [3, 4], [5, 6]], [[1, 2], [3, 4], [5, 6]], id="no_overlap"),
pytest.param([[1, 10], [2, 3], [4, 5], [6, 7]], [[1, 10]], id="all_merged"),
],
)
def test_merge_intervals(intervals, expected):
assert merge_intervals(intervals) == expected

@pytest.mark.parametrize("nums, expected", [
pytest.param([2, 2, 1], 1, id="simple_case"),
pytest.param([4, 1, 2, 1, 2], 4, id="middle_single"),
pytest.param([1], 1, id="single_element"),
pytest.param([100, 200, 300, 200, 100], 300, id="large_numbers"),
pytest.param([0, 1, 0], 1, id="with_zero"),
pytest.param([7, 8, 9, 8, 7], 9, id="unsorted"),
pytest.param([i + 10**5 for i in range(500)] + [i + 10**5 for i in range(500)] + [69], 69, id="long_list"),
])

@pytest.mark.parametrize(
"nums, expected",
[
pytest.param([2, 2, 1], 1, id="simple_case"),
pytest.param([4, 1, 2, 1, 2], 4, id="middle_single"),
pytest.param([1], 1, id="single_element"),
pytest.param([100, 200, 300, 200, 100], 300, id="large_numbers"),
pytest.param([0, 1, 0], 1, id="with_zero"),
pytest.param([7, 8, 9, 8, 7], 9, id="unsorted"),
pytest.param(
[i + 10**5 for i in range(500)] + [i + 10**5 for i in range(500)] + [69],
69,
id="long_list",
),
],
)
def test_find_single_number(nums, expected):
assert find_single_number(nums) == expected

@pytest.mark.parametrize("input_list, expected_list, expected_index", [
pytest.param([0, 1, 0, 3, 12], [1, 3, 12, 0, 0], 3, id="basic"),
pytest.param([0, 0, 1], [1, 0, 0], 1, id="zeros_first"),
pytest.param([1, 2, 3], [1, 2, 3], 3, id="no_zeros"),
pytest.param([0, 0, 0], [0, 0, 0], 0, id="all_zeros"),
pytest.param([1, 0, 2, 0, 3, 0], [1, 2, 3, 0, 0, 0], 3, id="interleaved"),
pytest.param([], [], 0, id="empty"),
pytest.param([0], [0], 0, id="single_zero"),
pytest.param([42], [42], 1, id="single_nonzero"),
])

@pytest.mark.parametrize(
"input_list, expected_list, expected_index",
[
pytest.param([0, 1, 0, 3, 12], [1, 3, 12, 0, 0], 3, id="basic"),
pytest.param([0, 0, 1], [1, 0, 0], 1, id="zeros_first"),
pytest.param([1, 2, 3], [1, 2, 3], 3, id="no_zeros"),
pytest.param([0, 0, 0], [0, 0, 0], 0, id="all_zeros"),
pytest.param([1, 0, 2, 0, 3, 0], [1, 2, 3, 0, 0, 0], 3, id="interleaved"),
pytest.param([], [], 0, id="empty"),
pytest.param([0], [0], 0, id="single_zero"),
pytest.param([42], [42], 1, id="single_nonzero"),
],
)
def test_move_zeros_to_end_parametrized(input_list, expected_list, expected_index):
arr = input_list[:]
result_index = move_zeros_to_end(arr)
assert arr == expected_list
assert result_index == expected_index


@pytest.mark.parametrize("matrix, expected_row", [
pytest.param(
[[0, 0, 1, 1],
[0, 1, 1, 1],
[0, 0, 0, 1],
[1, 1, 1, 1],
[0, 1, 1, 1]],
3,
id="classic"
),
pytest.param(
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
0,
id="all_zeros"
),
pytest.param(
[[1, 1, 1],
[1, 1, 1],
[1, 1, 1]],
0,
id="all_ones_first"
),
pytest.param(
[[0, 1],
[1, 1]],
1,
id="two_rows"
),
pytest.param(
[[0]],
0,
id="single_zero"
),
pytest.param(
[[1]],
0,
id="single_one"
),
pytest.param(
[],
0,
id="empty_matrix"
),
pytest.param(
[[0, 0, 1],
[0, 1, 1],
[0, 1, 1]],
1,
id="tie"
),
])
@pytest.mark.parametrize(
"matrix, expected_row",
[
pytest.param(
[[0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1]], 3, id="classic"
),
pytest.param([[0, 0, 0], [0, 0, 0], [0, 0, 0]], 0, id="all_zeros"),
pytest.param([[1, 1, 1], [1, 1, 1], [1, 1, 1]], 0, id="all_ones_first"),
pytest.param([[0, 1], [1, 1]], 1, id="two_rows"),
pytest.param([[0]], 0, id="single_zero"),
pytest.param([[1]], 0, id="single_one"),
pytest.param([], 0, id="empty_matrix"),
pytest.param([[0, 0, 1], [0, 1, 1], [0, 1, 1]], 1, id="tie"),
],
)
def test_find_row_with_most_ones(matrix, expected_row):
assert find_row_with_most_ones(matrix) == expected_row


def test_find_row_with_most_ones_big_data():
size = 10000
matrix = [[0]*size for i in range(size)]
matrix[size-1][size-1] = 1
matrix = [[0] * size for i in range(size)]
matrix[size - 1][size - 1] = 1

for i in range(50):
assert find_row_with_most_ones(matrix) == 9999

size = 10000
matrix = [[1]*size for i in range(size)]
matrix = [[1] * size for i in range(size)]
matrix[0][0] = 0

for i in range(50):
assert find_row_with_most_ones(matrix) == 1


@pytest.mark.parametrize("input_arr, expected", [
pytest.param([0], 1, id="self_loop"),
pytest.param([1, 0], 1, id="two_cycle"),
pytest.param([1, 2, 0], 1, id="three_cycle"),
pytest.param([0, 1, 2], 3, id="three_self_loops"),
pytest.param([1, 0, 3, 2], 2, id="two_2_cycles"),
pytest.param([2, 0, 1, 4, 3], 2, id="mixed_cycles"),
pytest.param([10, 6, 2, 9, 4, 0, 3, 8, 7, 1, 5], 5, id="mixed_cycles"),
pytest.param([], 0, id="empty"),
])
@pytest.mark.parametrize(
"input_arr, expected",
[
pytest.param([0], 1, id="self_loop"),
pytest.param([1, 0], 1, id="two_cycle"),
pytest.param([1, 2, 0], 1, id="three_cycle"),
pytest.param([0, 1, 2], 3, id="three_self_loops"),
pytest.param([1, 0, 3, 2], 2, id="two_2_cycles"),
pytest.param([2, 0, 1, 4, 3], 2, id="mixed_cycles"),
pytest.param([10, 6, 2, 9, 4, 0, 3, 8, 7, 1, 5], 5, id="mixed_cycles"),
pytest.param([], 0, id="empty"),
],
)
def test_count_cycles(input_arr, expected):
arr = input_arr[:]
assert count_cycles(arr) == expected
Loading
Loading