Skip to content

Made the code Python 3 compatible #407

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

Merged
merged 4 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "/usr/bin/python3"
}
9 changes: 5 additions & 4 deletions data_structures/Stacks/Stock-Span-Problem.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'''
The stock span problem is a financial problem where we have a series of n daily
price quotes for a stock and we need to calculate span of stocks price for all n days.
price quotes for a stock and we need to calculate span of stock's price for all n days.

The span Si of the stocks price on a given day i is defined as the maximum
The span Si of the stock's price on a given day i is defined as the maximum
number of consecutive days just before the given day, for which the price of the stock
on the current day is less than or equal to its price on the given day.
'''
from __future__ import print_function
def calculateSpan(price, S):

n = len(price)
Expand Down Expand Up @@ -37,7 +38,7 @@ def calculateSpan(price, S):
# A utility function to print elements of array
def printArray(arr, n):
for i in range(0,n):
print arr[i],
print (arr[i],end =" ")
Copy link
Member

Choose a reason for hiding this comment

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

Please delete the space... print (arr[i],end =" ") --> print(arr[i], end=" ")

print() is now a function like all other functions so it should be formatted in the same way.



# Driver program to test above function
Expand All @@ -48,4 +49,4 @@ def printArray(arr, n):
calculateSpan(price, S)

# Print the calculated span values
printArray(S, len(price))
printArray(S, len(price))