Skip to content

Alexis aros #110

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 6 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions eating_cookies/eating_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
Input: an integer
Returns: an integer
'''
def eating_cookies(n):
# Your code here

pass
def eating_cookies(n,):

if n == 0:
return 1
if n < 0:
return 0
return eating_cookies(n-1) + eating_cookies(n-2) + eating_cookies(n-3)

if __name__ == "__main__":
# Use the main function here to test out your implementation
Expand Down
6 changes: 4 additions & 2 deletions moving_zeroes/moving_zeroes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
'''
def moving_zeroes(arr):
# Your code here

pass
for i in arr:
if i == 0:
arr.append(arr.pop(arr.index(i)))
return arr


if __name__ == '__main__':
Expand Down
10 changes: 9 additions & 1 deletion product_of_all_other_numbers/product_of_all_other_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
Input: a List of integers
Returns: a List of integers
'''

from functools import reduce

def product_of_all_other_numbers(arr):
# Your code here
prod = []

pass
for num in range(0, len(arr)):
prod.append(reduce(lambda x, y: x*y,
[x for i, x in enumerate(arr) if i != num]))
return prod



if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion single_number/single_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
'''
def single_number(arr):
# Your code here
return 2 * sum(set(arr)) - sum(arr)

pass


if __name__ == '__main__':
Expand Down
7 changes: 5 additions & 2 deletions sliding_window_max/sliding_window_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
'''
def sliding_window_max(nums, k):
# Your code here

pass
con = []
while k < len(nums) + 1:
con.append(max(nums[0:k]))
nums.pop(0)
return con


if __name__ == '__main__':
Expand Down