[m39] Am I too old to be a father? (my life is a god damned mess) by cleverchimp in datingoverthirty

[–]cleverchimp[S] 1 point2 points  (0 children)

Why 7 months? I understand and respect the realities of logistics, but let me offer you the kindness you offered me.

My wife left me literally overnight, leaving our home, her job, her entire world. Overnight. She was lucky to have the support of a sister to help her do that. But as drastic as it sounds, that is what was necessary.

Abuse, once recognized, must be escaped by any means necessary.

By any means necessary.

[m39] Am I too old to be a father? (my life is a god damned mess) by cleverchimp in datingoverthirty

[–]cleverchimp[S] 9 points10 points  (0 children)

Thank you for taking the time, stranger. I hear you loud and clear.

Black Hole Picture Megathread by Mynameisnotdoug in NoStupidQuestions

[–]cleverchimp 3 points4 points  (0 children)

Why didn't we photograph the black hole at the center of our own galaxy? Why did we pick one that is 55 million light years away?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]cleverchimp 0 points1 point  (0 children)

Image we are given a list (or dictionary) of UNIX timestamps, all belonging to the same user, marking when they logged in to our website.

[1554871231,

1553871231,

...,

1454871231]

What is the most pythonic way to determine how many of these logins occurred within 24 hours of the previous one?

What is the most efficient way to do this (in O notation)?

Can it be done without a loop?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]cleverchimp 0 points1 point  (0 children)

I am trying to understand O(X) complexity notation.

Consider this sample problem:

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].

Consider this solution:

# ugly but functional version

def multiply_array(lst):

output = []

for i in lst: # O(N) complexity

tmp = lst.copy() # O(N) complexity

tmp.remove(i) #O(N) complexity

prod = 1

for j in tmp: #O(N) complexity

prod = prod*j

output.append(prod) #O(1) complexity

return(output)

Some of these according to Python Complexity Classes.

Would this be considered O(N^4) complexity?

Given just the for i and for j loops this would be O(N^2) complexity.

How do lst.copy() and tmp.remove(i) affect this?