Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sourcery refactored development branch #2

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
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 10, 2023

Branch development 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 development branch, then run:

git fetch origin sourcery/development
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from JoshuaNgugi April 10, 2023 08:03
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -9 to +12
print("Creating " + file_name + "in java and python dir...")
with open("python/" + file_name + ".py", 'w'):
print(f"Creating {file_name}in java and python dir...")
with open(f"python/{file_name}.py", 'w'):
pass
with open("java/" + file_name + ".java", 'w'):
with open(f"java/{file_name}.java", 'w'):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 9-12 refactored with the following changes:

temp_s = '#'.join('{}'.format(s))
temp_s = '#'.join(f'{s}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.longestPalindrome refactored with the following changes:

Comment on lines -4 to +14
flag = True if x < 0 else False
flag = x < 0
if flag:
x = -x
x = str(x)[::-1]

if flag:
x = "-" + x
x = f"-{x}"

value = 2 ** 31
x = int(x)
if -value <= x < value:
return x
return 0
return x if -value <= x < value else 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.reverse refactored with the following changes:

Comment on lines -13 to +22
if pos < ls and str[pos] == '-':
sign = -1
pos += 1
elif pos < ls and str[pos] == '+':
pos += 1
if pos < ls:
if str[pos] == '-':
sign = -1
pos += 1
elif str[pos] == '+':
pos += 1
while pos < ls and ord(str[pos]) >= ord('0') and ord(str[pos]) <= ord('9'):
num = ord(str[pos]) - ord('0')
if result > max_int / 10 or ( result == max_int / 10 and num >= 8):
if sign == -1:
return min_int
return max_int
return min_int if sign == -1 else max_int
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.myAtoi refactored with the following changes:

if (x == x[::-1]):
return True
return False
return x == x[::-1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.isPalindrome refactored with the following changes:

Comment on lines -12 to +14
for j in range(i + 1, ls):
# append ascending order pair
if nums[i] < nums[j]:
pair.append([i,j])
pair.extend([i,j] for j in range(i + 1, ls) if nums[i] < nums[j])
pos = 0
if len(pair) > 0:
if pair:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.nextPermutation refactored with the following changes:

This removes the following comments ( why? ):

# append ascending order pair

Comment on lines -31 to +33
else:
if len(stack) > 0:
data[i] = 1
data[stack.pop(-1)] = 1
elif stack:
data[i] = 1
data[stack.pop(-1)] = 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.longestValidParentheses refactored with the following changes:

Comment on lines -26 to +33
l, r = int(0), len(nums) - 1
l, r = 0, len(nums) - 1
while l < r:
mid = int((l + r) / 2)
if nums[mid] < target:
l = mid + 1
else:
r = mid
if nums[l] < target:
return l + 1
return l
return l + 1 if nums[l] < target else l
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.searchInsert refactored with the following changes:

for j in range(9):
if board[i][j] == '.':
empty.append(9 * i + j)
empty.extend(9 * i + j for j in range(9) if board[i][j] == '.')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.solveSudoku refactored with the following changes:

Comment on lines -40 to +42
step = 0
for index in range(start + 1, end):
if height[index] > 0:
step += height[index]
step = sum(
height[index] for index in range(start + 1, end) if height[index] > 0
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Solution.rain_water refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants