Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Ruff

on:
push:

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed Python files
id: changed-files
run: |
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.py$' | tr '\n' ' ' || true)
echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "Changed Python files: $CHANGED_FILES"

- name: Run Ruff on changed files
if: steps.changed-files.outputs.changed_files != ''
uses: astral-sh/ruff-action@v3
with:
version: "0.4.4"
args: "check --output-format=github ${{ steps.changed-files.outputs.changed_files }}"

- name: No Python files changed
if: steps.changed-files.outputs.changed_files == ''
run: echo "No Python files to check"
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.ruff]
target-version = "py312"

[tool.ruff.lint]
extend-select = [
"F", # Правила Pyflakes
"W", # Предупреждения PyCodeStyle
"E", # Ошибки PyCodeStyle
"I", # Правильно сортировать импорты
"N", # Нейминг
"UP", # Предупреждать, если что-то можно изменить из-за новых версий Python
"C4", # Ловить неправильное использование comprehensions, dict, list и т.д.
"FA", # Применять from __future__ import annotations
"ISC", # Хорошее использование конкатенации строк
"ICN", # Использовать общие соглашения об импорте
"RET", # Хорошие практики возврата
"SIM", # Общие правила упрощения
]
18 changes: 10 additions & 8 deletions src/SecondHomeworks/Extended_Euclid.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
def extended_gcd(a, b):
remainder0, remainder1 = a, b
factorA0, factorA1 = 1, 0
factorB0, factorB1 = 0, 1
factor_a0, factor_a1 = 1, 0
factor_b0, factor_b1 = 0, 1

while remainder1 != 0:
quotient = remainder0 // remainder1
remainder0, remainder1 = remainder1, remainder0 - quotient * remainder1
factorA0, factorA1 = factorA1, factorA0 - quotient * factorA1
factorB0, factorB1 = factorB1, factorB0 - quotient * factorB1
factor_a0, factor_a1 = factor_a1, factor_a0 - quotient * factor_a1
factor_b0, factor_b1 = factor_b1, factor_b0 - quotient * factor_b1

return remainder0, factorA0, factorB0
A, B = int(input()), int(input())
gcd, factorA, factorB = extended_gcd(A, B)
return remainder0, factor_a0, factor_b0


a, b = int(input()), int(input())
gcd, factor_a, factor_b = extended_gcd(a, b)
print(f"GCD = {gcd}")
print(f"({factorA}) * {A} + ({factorB}) * {B} = {gcd}")
print(f"({factor_a}) * {a} + ({factor_b}) * {b} = {gcd}")