This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def large_cont_sum(arr): | |
# Check to see if array is length 0 | |
if len(arr)==0: | |
return 0 | |
# Start the max and current sum at the first element | |
max_sum=current_sum=arr[0] | |
# For every element in array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compress(s): | |
run = "" | |
length = len(s) | |
if length == 0: | |
return "" | |
# "A" --> "A1" | |
if length == 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def profit(stock_prices): | |
if len(stock_prices) < 2: | |
return "Hey I need more prices!" | |
min_stock_price = stock_prices[0] | |
max_profit = 0 | |
for price in stock_prices: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def finder(arr1,arr2): | |
arr1.sort() | |
arr2.sort() | |
for num1,num2 in zip(arr1,arr2): | |
if num1 != num2: | |
return num1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(): | |
print('Hello World') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(name): | |
#return 'Hello {}'.format(name) | |
print('Hello {}'.format(name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(x): | |
if x == True: | |
# print('Hello') | |
return 'Hello' | |
elif x == False: | |
# print('Goodbye') | |
return 'Goodbye' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(x,y,z): | |
if z: | |
# print(x) | |
return x | |
else: | |
# print(y) | |
return y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(a,b): | |
print(a+b) | |
# return a+b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_even(n): | |
if n%2 == 0: | |
return True | |
# print(True) **tested to make sure it DOESN'T work | |
else: | |
return False |
OlderNewer