-
Notifications
You must be signed in to change notification settings - Fork 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
Sourcery refactored master branch #7
base: master
Are you sure you want to change the base?
Conversation
elif a == "easy-medium" or a == "medium": | ||
elif a in ["easy-medium", "medium"]: |
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.
Lines 13-13
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
ans = 0 | ||
for i in range(4,len(a)+1): | ||
li.append(a[count:i]) | ||
count += 1 | ||
|
||
for i in li: | ||
if "c" in i and "h" in i and "e" in i and "f" in i: | ||
ans += 1 | ||
|
||
ans = sum(1 for i in li if "c" in i and "h" in i and "e" in i and "f" in i) | ||
if ans == 0: | ||
print("normal") | ||
else: | ||
print("lovely",ans) | ||
|
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.
Lines 6-18
refactored with the following changes:
- Convert for loop into call to sum() (
sum-comprehension
)
for i in range(user_test): | ||
for _ in range(user_test): | ||
user_string = input().split() | ||
cases.append(user_string) | ||
|
||
for i in range(len(cases)): | ||
for j in range(len(cases[i])): | ||
cases[i][j] = int(cases[i][j]) | ||
for case_ in cases: | ||
for j in range(len(case_)): | ||
case_[j] = int(case_[j]) | ||
|
||
for i in range(len(cases)): | ||
if (cases[i][0] * (2 ** 0.5) / cases[i][1]) < (cases[i][0] / cases[i][2] * 2): | ||
for case in cases: | ||
if case[0] * 2 ** 0.5 / case[1] < case[0] / case[2] * 2: |
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.
Lines 7-16
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
) - Replace index in for loop with direct reference (
for-index-replacement
)
|
||
for i in range(n): | ||
if n_hand[i] <= n_glove[i]: | ||
front += 1 | ||
if n_hand[i] <= n_glove[n-1-i]: | ||
back += 1 | ||
|
||
if front == n == back: | ||
print("both") | ||
elif front == n and back != n: | ||
elif front == n: | ||
print("front") | ||
elif back == n and front != n: | ||
elif back == n: |
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.
Lines 8-19
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
for i in l: | ||
if i[2] == g: | ||
return True | ||
return False | ||
return any(i[2] == g for i in l) |
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.
Function compare
refactored with the following changes:
- Use any() instead of for loop (
use-any
)
new_list = [] | ||
for _ in range(n): | ||
new_list.append(0) | ||
|
||
new_list = [0 for _ in range(n)] |
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.
Lines 6-20
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
for j in n_colors: | ||
for _ in n_colors: |
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.
Lines 13-13
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for i in range(n): | ||
for _ in range(n): |
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.
Lines 5-5
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
while(binary != 0): | ||
while (binary != 0): | ||
dec = binary % 10 | ||
decimal = decimal + dec * pow(2, i) | ||
decimal += dec * pow(2, i) |
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.
Function binaryToDecimal
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
|
||
for i in n_numbers[l-1: r]: | ||
temp = bin(i) | ||
bin_n_numbers.append(temp[2:]) | ||
length_temp = len(temp[2:]) | ||
if max_len < length_temp: | ||
max_len = length_temp | ||
|
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.
Lines 18-44
refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Remove redundant conditional (
remove-redundant-if
) - Replace if statement with if expression (
assign-if-exp
) - Replace index in for loop with direct reference (
for-index-replacement
)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.25 out of 10.
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: