Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Placing Parentheses and update README #2222
Conversation
TravisBuddy
commented
Jul 21, 2020
|
Hey @srivastavaayu, TravisCI finished with status TravisBuddy Request Identifier: d9303e30-cb93-11ea-96be-d1d226963d5e |
|
Read the CONTRIBUTING.md and add type hints, doctests and proper flake8 formatting |
|
@cclauss, please review this one |
|
Codespell says:
|
Updated parentheses.py with type hints, checked code formatting using black and flake8
TravisBuddy
commented
Jul 22, 2020
Travis tests have failedHey @srivastavaayu, TravisBuddy Request Identifier: 4ac548a0-cc4e-11ea-acda-6fc69b852bf0 |
Updated parentheses.py with type hints, checked code formatting using black and flake8
TravisBuddy
commented
Jul 22, 2020
Travis tests have failedHey @srivastavaayu, TravisBuddy Request Identifier: 93fbd1c0-cc52-11ea-acda-6fc69b852bf0 |
|
https://docs.python.org/3/library/operator.html from operator import add, sub, mul, floordiv
operators = {
"+": add,
"-": sub,
"*": mul,
"/": floordiv, # or truediv,
}
def calculate(a: int, b: int, op: str) -> int:
return operators[op](a, b) |
Update parentheses.py and now using built-in addition, subtraction, and multiplication operators and also renamed variables to reflect their purpose.
TravisBuddy
commented
Jul 22, 2020
|
Hey @srivastavaayu, TravisCI finished with status TravisBuddy Request Identifier: 27f19b50-cc65-11ea-acda-6fc69b852bf0 |
TravisBuddy
commented
Jul 22, 2020
|
Hey @srivastavaayu, TravisCI finished with status TravisBuddy Request Identifier: 333e1aa0-cc66-11ea-acda-6fc69b852bf0 |
TravisBuddy
commented
Jul 22, 2020
Travis tests have failedHey @srivastavaayu, TravisBuddy Request Identifier: 357ca380-cc67-11ea-acda-6fc69b852bf0 |
|
@cclauss I don't understand. I've possibly done every change suggested by you. Let me try and incorporate changes suggested by you once again. But is there any specific reason the build is failing? |
|
The main code with an |
|
|
||
| def calculate(first_operand, second_operand, operator) -> int: | ||
| """ | ||
| Return the value after evaluating the expression |
This comment has been minimized.
This comment has been minimized.
cclauss
Jul 23, 2020
•
Member
Type hints on function parameters needed and doc tests needed.
Please add the following doctest...
| Return the value after evaluating the expression | |
| Evaluate the expression and return the result. | |
| >>> calculate("2+2") # add() | |
| 4 | |
| >>> calculate("2-2") # sub() | |
| 0 | |
| >>> calculate("2*2") # mul | |
| 4 |
Once this is done, on you local machine, do python3 -m doctest -v paraentheses.py
doctests are how we ensure that our function works the way that we think it should and how we document to others how it should be called.
| return operators[operator](first_operand, second_operand) | ||
|
|
||
|
|
||
| def MinandMax(maximum_numbers, minimum_numbers, i, j, operator) -> int: |
This comment has been minimized.
This comment has been minimized.
|
@cclauss All the tests have passed successfully. Please review this PR. And suggest changes, if any. |
|
@srivastavaayu Thanks for the contribution! Could you add a few doctests & type hints and comment (what's the expected input and output) in the code to demonstrate the function? We need these to have this landed. If you're in doubt, you can see our CONTRIBUTING.md that will give you a clearer idea. |
srivastavaayu commentedJul 21, 2020
•
edited
Added Placing Parenthesis (the question is to maximize an expression by rearranging operands and operators) in the Dynamic Programming subdirectory.
Add repo license details with a link to the license file in the directory.
Checklist:
Fixes: #{$ISSUE_NO}.