mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038) * refactor: Fix naming conventions (#7038) * Update arithmetic_analysis/lu_decomposition.py Co-authored-by: Christian Clauss <cclauss@me.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038) * chore: Fix naming conventions in doctests (#7038) * fix: Temporarily disable project euler problem 104 (#7069) * chore: Fix naming conventions in doctests (#7038) Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -8,7 +8,7 @@ on the current day is less than or equal to its price on the given day.
|
||||
"""
|
||||
|
||||
|
||||
def calculateSpan(price, S):
|
||||
def calculation_span(price, s):
|
||||
|
||||
n = len(price)
|
||||
# Create a stack and push index of fist element to it
|
||||
@ -16,7 +16,7 @@ def calculateSpan(price, S):
|
||||
st.append(0)
|
||||
|
||||
# Span value of first element is always 1
|
||||
S[0] = 1
|
||||
s[0] = 1
|
||||
|
||||
# Calculate span values for rest of the elements
|
||||
for i in range(1, n):
|
||||
@ -30,14 +30,14 @@ def calculateSpan(price, S):
|
||||
# than all elements on left of it, i.e. price[0],
|
||||
# price[1], ..price[i-1]. Else the price[i] is
|
||||
# greater than elements after top of stack
|
||||
S[i] = i + 1 if len(st) <= 0 else (i - st[0])
|
||||
s[i] = i + 1 if len(st) <= 0 else (i - st[0])
|
||||
|
||||
# Push this element to stack
|
||||
st.append(i)
|
||||
|
||||
|
||||
# A utility function to print elements of array
|
||||
def printArray(arr, n):
|
||||
def print_array(arr, n):
|
||||
for i in range(0, n):
|
||||
print(arr[i], end=" ")
|
||||
|
||||
@ -47,7 +47,7 @@ price = [10, 4, 5, 90, 120, 80]
|
||||
S = [0 for i in range(len(price) + 1)]
|
||||
|
||||
# Fill the span values in array S[]
|
||||
calculateSpan(price, S)
|
||||
calculation_span(price, S)
|
||||
|
||||
# Print the calculated span values
|
||||
printArray(S, len(price))
|
||||
print_array(S, len(price))
|
||||
|
Reference in New Issue
Block a user