-
Notifications
You must be signed in to change notification settings - Fork 0
Домашнее задание 5.1. Оформление задачи. Разгуляева А.И. #5
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
Open
ada1ra
wants to merge
8
commits into
main
Choose a base branch
from
hw_5-1_format
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
499829c
Add rewrited code from task 1.4
ada1ra 0bb6ca8
Add pyproject.toml
ada1ra bbe5101
Update ruff.yml
ada1ra bfb819f
Fix format in homework
ada1ra df16cc0
Fix format for ruff
ada1ra 2ac83c6
Fix format for ruff
ada1ra dc46554
Merge branch 'main' into hw_5-1_format
ada1ra b10fe8d
Fix format after merge main
ada1ra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # У вас есть монеты номиналом в длина имени, длина фамилии, длина отчества(если нет, то 19). | ||
| # Напишите программу, выписывающую размен считанного с консоли числа, если таковой возможен. | ||
| # В противном случае выведите "-42!". | ||
| # 3, 10, 8 | ||
|
|
||
| COIN_1 = 10 # номинал 1-ой монеты | ||
| COIN_2 = 8 # номинал 2-ой монеты | ||
| COIN_3 = 3 # номинал 3-ей монеты | ||
| take = "" # число для размена, взятое через input | ||
| test = 0 # переменная-флаг для проверки правильности введённого формата | ||
|
|
||
| # проверка правильности введённого формата | ||
| while test == 0: | ||
| try: | ||
| take = int(input("Введите число для размена: ")) | ||
| test = 1 | ||
| except ValueError: | ||
| print("Неверный формат!") | ||
|
|
||
|
|
||
| def change(x=0, y=take, z=[0, 0, 0]): | ||
| global COIN_1, COIN_2, COIN_3 | ||
|
|
||
| if x == y: | ||
| return z # нашли решение, возвращаем его | ||
|
|
||
| if x > y: | ||
| return None # превышение суммы, нет решения | ||
|
|
||
| # пробуем добавить монету COIN_1 | ||
| res = change(x + COIN_1, y, [z[0] + 1, z[1], z[2]]) | ||
| if res is not None: | ||
| return res | ||
|
|
||
| # пробуем добавить монету COIN_2 | ||
| res = change(x + COIN_2, y, [z[0], z[1] + 1, z[2]]) | ||
| if res is not None: | ||
| return res | ||
|
|
||
| # пробуем добавить монету COIN_3 | ||
| res = change(x + COIN_3, y, [z[0], z[1], z[2] + 1]) | ||
| if res is not None: | ||
| return res | ||
|
|
||
| return None # решений нет | ||
|
|
||
|
|
||
| result = change() | ||
|
|
||
| if result is None: | ||
| print("-42!") | ||
| else: | ||
| print( | ||
| f"{result[0]} монет по {COIN_1}, {result[1]} монет по {COIN_2} и {result[2]} монет по {COIN_3}." | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.