Conversation
| elif a == "easy": | ||
| e += 1 | ||
| elif a == "easy-medium" or a == "medium": | ||
| elif a in ["easy-medium", "medium"]: |
There was a problem hiding this comment.
Lines 13-13 refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (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.
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.
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.
Lines 8-19 refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
| if i[2] == g: | ||
| return True | ||
| return False | ||
| return any(i[2] == g for i in l) |
There was a problem hiding this comment.
Function compare refactored with the following changes:
- Use any() instead of for loop (
use-any)
| for _ in range(n): | ||
| new_list.append(0) | ||
|
|
||
| new_list = [0 for _ in range(n)] |
There was a problem hiding this comment.
Lines 6-20 refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| for i in n_colors: | ||
| dict_n[i] = 0 | ||
| for j in n_colors: | ||
| for _ in n_colors: |
There was a problem hiding this comment.
Lines 13-13 refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| s,t = 0,0 | ||
| n = int(input()) | ||
| for i in range(n): | ||
| for _ in range(n): |
There was a problem hiding this comment.
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.
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.
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
masterrefactored 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
masterbranch, then run: