Tighten up psf/black and flake8 (#2024)

* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2020-05-22 08:10:11 +02:00
committed by GitHub
parent 21ed8968c0
commit 1f8a21d727
124 changed files with 583 additions and 495 deletions

View File

@ -22,7 +22,7 @@ import operator as op
def Solve(Postfix):
Stack = []
Div = lambda x, y: int(x / y) # integer division operation
Div = lambda x, y: int(x / y) # noqa: E731 integer division operation
Opr = {
"^": op.pow,
"*": op.mul,
@ -38,29 +38,27 @@ def Solve(Postfix):
for x in Postfix:
if x.isdigit(): # if x in digit
Stack.append(x) # append x to stack
print(
x.rjust(8), ("push(" + x + ")").ljust(12), ",".join(Stack), sep=" | "
) # output in tabular format
# output in tabular format
print(x.rjust(8), ("push(" + x + ")").ljust(12), ",".join(Stack), sep=" | ")
else:
B = Stack.pop() # pop stack
print(
"".rjust(8), ("pop(" + B + ")").ljust(12), ",".join(Stack), sep=" | "
) # output in tabular format
# output in tabular format
print("".rjust(8), ("pop(" + B + ")").ljust(12), ",".join(Stack), sep=" | ")
A = Stack.pop() # pop stack
print(
"".rjust(8), ("pop(" + A + ")").ljust(12), ",".join(Stack), sep=" | "
) # output in tabular format
# output in tabular format
print("".rjust(8), ("pop(" + A + ")").ljust(12), ",".join(Stack), sep=" | ")
Stack.append(
str(Opr[x](int(A), int(B)))
) # evaluate the 2 values popped from stack & push result to stack
# output in tabular format
print(
x.rjust(8),
("push(" + A + x + B + ")").ljust(12),
",".join(Stack),
sep=" | ",
) # output in tabular format
)
return int(Stack[0])