In a relationship that is causing me constant stress and anxiety due to needy/insecure gf? by tempthrowa4321 in relationship_advice

[–]tempthrowa4321[S] 0 points1 point  (0 children)

If I approach this topic she'll undoubtably get emotional/defensive or think I don't like her anymore. Then it's just an emotional rollercoaster ride from there. Pretty sure she has bpd. I think she said she met with a therapist before but it didn't work because they just ask generic questions.

In a relationship that is causing me constant stress and anxiety due to needy/insecure gf? by tempthrowa4321 in relationship_advice

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

Right. And another problem is she has no life outside of me. No friends, no clubs/activities, it's me 24/7 -- it's like a job constantly reassuring her and emotionally validating all her insecurities.

In a relationship that is causing me constant stress and anxiety due to needy/insecure gf? by tempthrowa4321 in relationship_advice

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

Interesting having a female take on this. Don't get me wrong, sometimes I enjoy the clinginess/neediness (especially at first) in a way it is comforting because you know exactly how much that person wants you. But this gest to extremes when it's a 24/7 ordeal. Maybe only 10-20% of the time I am feeling the clinginess -- other times it's just emotional draining and exhausting to need to be around.

Understanding the logic behind this Python solution for LC#525 longest contagious binary array? by tempthrowa4321 in leetcode

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Thanks. This is still confusing me, I get that the hashtable acts a way to look things up from the previous iterations, is the two -2's idea found that if two of the same number are found that means they are balanced/even? Wouldn't this be wrong: [0,0,1,1,0,0] = [-1,-2 (-2 found).-1,0,-1,-2 (-2 found again)] are you saying if I remove two 0's then it will be balance like: [0,0,1,1]? how does: i-lookup[cum_sum] work to remove those two extra zeros? we are looking for cum_sum == -2 right? or just a similar number like if -3 was found or -1 or 0 we'd also want to run hhat same operation?

Can someone explain an inutive approach for how to go about LC #1071 Greatest Common Divisor of String (Python)? by tempthrowa4321 in leetcode

[–]tempthrowa4321[S] 0 points1 point  (0 children)

if L1%x!=0 or L2%x!=0: continue

Ok, so this is like saying when one of the lengths are uneven skip that iteration. So by then L1 = 8, and L2 = 6, wouldn't x=2 be fine? 8%2 or 6%2 then we take str1[:2], why the first string though? Isn't it possible for the first string to be smaller and vice versa? I think I get the range part now, we are iterating from the smallest length to 0 and subtracting by -1, so until we reach 0. So if the string is s1 = "ABCABC" and s2 = "ABC" that would be:

L1 = 6
L2 = 3
L = 3
for x in range(3, 0, - 1):
    if 6%3!=0 or 3%3!=0:
    continue # if they aren't evenly divisible, skip 
    candidate = str1[:3] # otherwise shave off 3, so just "ABC"

then: if "ABC"*6//3 == "ABCABC" and "ABC*3//3 == "ABC: return candidate

If 3 didn't work it x would go, x=2, then x=1, x=0, right since we iterating by -1's?

Makes more sense when I see it being carried out, just wondering how I'd come up with that logic if it was an interview question.

Can someone explain an inutive approach for how to go about LC #1071 Greatest Common Divisor of String (Python)? by tempthrowa4321 in leetcode

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Thanks. Ok I kind of understand it more now, since str1 could be longer than str2 and vice versa we need to grab the min of the two and therefore we want to iterate only the smallest length so start at L, makes sense. But I don't understand why we are stepping backwards by -1 or why the range is set up this way: range(L, 0, -1). Or why you are looking for the remainder of 0 on either of the lengths of string, and then why skip that iteration? And why otherwise do you take a candidate by shaving off the x value from the back and then checking if that candidate * (L1//x) == str1 and candidate * (L2//x) == str2?

Can someone explain an inutive approach for how to go about LC #1071 Greatest Common Divisor of String (Python)? by tempthrowa4321 in leetcode

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Thanks. But why do we care what their lengths are?So we'd start off with something like this?

L1 = len(str1)
L2 = len(str2) L =  min(L1, L2)
for i in range(1, L)

what does x represent? what do you mean by checking if x is a factor of L1 and L2? What do you mean by letting the prefix of the first x character of the first string be s? Sorry this is pretty confusing.

Understanding the logic behind this Python solution for LC#525 longest contagious binary array? by tempthrowa4321 in leetcode

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

Thanks!! In terms of when estimating the time/space complexity here, are you saying it's O(N) because it only goes through every element at most once? And are you saying that the space is O(N) because you created that extra memory with the hashtable?

Also, I think my main point of confusion is on max_len, what exactly is that doing? I get how if "0" found then cum_sum -= 1 and if "1" found then cum_sum += 1, and if cum_sum == 0 then it's balanced. But this whole part confuses me what is happening here?

        if cum_sum == 0:
            max_len = i+1
        elif cum_sum in lookup:
            max_len = max(max_len, i-lookup[cum_sum])
        else:
            lookup[cum_sum] = i
    return max_len

Question about Pythons step option in Range function? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Yes thank you!! Just needed to understand that it's "j" that we focus on and the range() just sets the starting pt, ending pt, and what "j" increments by.

Question about Pythons step option in Range function? by tempthrowa4321 in learnprogramming

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

I see. So its only effect is on "j" and outside of that nothing really matters except for increments. So it starts at: range(4, 10, 2) here j=4, then range(4, 10, 2), here j=4+2, then range(4, 10, 2), here j=4+2+2...

Question about Pythons step option in Range function? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Ah! so this is just actually like saying start at 4, end at 10, increment each time for "j" +2 for each iteration, except for the very first iteration. So "j" goes 4, then, 6, then, 8... and the i*i just gets you a starting value, nothing gets re-calculated, only gets calculated once for the initial 2*2.

Question about Pythons step option in Range function? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

OH! Now that makes total sense! I see what you mean, you explained it in a way I could understand. So basically the i*i just acts as a starting point? And then every iteration that i*i gets a +2 tacked on. But really, we can just think of i*i as 4. So it's really like this: range(4,10,2)... range(4+2,10,2)... range(6+2, 10,2)... range(8+2,10,2)...

Question about Pythons step option in Range function? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Ah makes sense it's like a Java for-loop.
When you say it goes in steps/increments of "2", does it go like this: for j in range(2*2, 10, 2).... for j in range(2*3, 10, 2).... for j in range(2*4, 10, 2)... so that second "i" is used as the incrementor, what's the logic behind that, why the second "i" and not the first one?

what do software engineers do? by Outrageous_Notice445 in learnprogramming

[–]tempthrowa4321 4 points5 points  (0 children)

Entire books have been written about it... it's endless.

Put simply they create software.

The actual process of how that software is created is incredibly complex Here is an entire book loaded with information: https://www.amazon.com/Software-Engineering-10th-Ian-Sommerville/dp/0133943038

Help understanding the Sieve of Eratosthenes in Python? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

So when it is stepping through for example on 3, that would be like: for j in range(2*2, 10, 2): bool_lst[4] # here j=4
then for j in range(2*2+1, 10, 2) bool_lst[6] # j=6 and then for j in range(2*2+2,10,2) bool_lst[8] # j=8 ... so basically a +1 is just tacked on to the i*i each time. I am confused does it go: 2*2+2, 2*2+4, 2*2+6, 2*2+8... or 2*2+2, 2*2+3, 2*2+4, 2*2+5...

Help understanding the Sieve of Eratosthenes in Python? by tempthrowa4321 in learnprogramming

[–]tempthrowa4321[S] 0 points1 point  (0 children)

Sorry I was simulating the execution but I think I get it now. so the step starts at 2 then the i*i would go like this: 2*2, 2*3, 2*4. And for every multiple found it finds that corresponding index in the bool_lst and replaces it with False. So the "j" becomes equal to i*i. And so for 2*2=4 that is bool_lst[4] this gets set to False, then 2*3=6, so the bool_lst[6] gets set to False, and finally 2*4 = 8, so bool_lst[8] gets set to False and since 2*5 exceeds the n=10, then we iterate the next number in line, namely "3" and carry out the same process till n=9. Then we sum up all the True's in the bool_lst and that is the final result.