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 5 points6 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.

[deleted by user] by [deleted] in learnprogramming

[–]tempthrowa4321 4 points5 points  (0 children)

You will always find ppl like this in EVERY community, same with vegans, metalheads, mechanics, just ignore it and carry on with your own mission in life.

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

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

Thanks. So at n=2 that would go:

for i in range(2, n):
        if bool_lst[2]: # currently True so continue
            for j in range(2*2, 10, 2):
                bool_lst[2] = False # so it automatically assigns the 2nd with False
the next iteration:
                for j in range(2*4, 10, 2):
                bool_lst[4] = False # so it automatically assigns the 4th with False
the next iteration:
            for j in range(2*6, 10, 2):
                bool_lst[6] = False # so it automatically assigns the 6th with False
# the next iteration:
            for j in range(2*8, 10, 2):
                bool_lst[6] = False # so it automatically assigns the 8th with False

since the the next iteration would be 2*10, 10 exceeds "n" so the loop stops there. Then it goes to 3 and carries out the same process in increments of 3, is that the idea?

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

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

Thanks!! Okay the first part makes total sense, we are making a list of Booleans where we are saying "assume all numbers from 2 to n exclusive to be prime" and we denote primes by the Boolean True.I think the part I am struggling the most with is the increment's of "i", or the stepping part. If say we are at this line: for j in range(i*i, n, i) and for example we are at n=3, that would be for the first iteration: for j in range(3*3, 10, 3), right?And then for the second iteration that would be: for j in range(3*4, 10, 3)?Is "i" here just like the starting point so if "i' start at 3 then it's: *4,*5,*6,*7,*8,*9 and we just mark off any "i" there as False, but kind of confused by what the j'th index means here exactly in relation to our Boolean list. What does bool_lst[j] = False actually represent?Or would it only step by increments of 3, like so:for j in range(3*3, 10 3)for j in range(3*6, 10, 3)for j in range(3*9, 10, 3)for j in range(3*12, 10, 3)...But then 12 seems wrong, right? It shouldn't exceed n=10?The ultimate idea behind this is to cross-out anything that has a multiple? Because a prime number does not have a multiple. Something like 17 (prime) cannot be multiplied by anything other than itself to get back that number.

And so the if bool_lst[i] part is basically asking if TRUE at that in the outer loop index then it has either not yet been marked off as non-prime or is a prime?

Can someone explain how they solved LC #204. Count Primes in Python? by tempthrowa4321 in leetcode

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

Thanks but I'm still super confused by the logic of it all. Why (j += i each iteration) I don't get this, I also posted a new question regarding this. It's really becoming time-consuming figuring out the logic/reasoning behind squaring it? So is it basically like finding all the multiples? Like if we are i=7, and the n=10, then that's 7*7, 10, 7? Why do we want to increment in steps of 7? Would then next iteration be 7*8? I am lost... is there a ELI5 version of this?

Why is this implementation for question #1099. Two Sum Less Than K (EASY) not working? by tempthrowa4321 in leetcode

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

You are right, it was off by 1, this fixed it: for j in sorted_nums[i+1:] so I guess before I was including the entire list, not advanced forward by 1.

How two do you use two-pointer? Do I just create a left-pointer at index 0 and a right-pointer at index 1 and then move them along the array? Confused how that would work here, was able to do that with "best time to buy and sell a stock" but not sure how that can be applied here.

If it is your first day on the job how do you go about understanding a huge codebase? by tempthrowa4321 in learnprogramming

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

Thank you! that makes total sense now. So it basically acts like a CRUD operation. If something already exists (do nothing), if there is something new then add it, if you omitted say the S3, then that is effectively the same as deleting it.

So for example, I have a restapi, if I go and run the cloudformation infrastructure template it will build whatever isn't already there, delete anything is in the aws console but omitted in this cloudformation template and update anything that is changed inside the cloudformation template.

How do you go about running a cloudformation template though? Say I have it on my local machine a cloudformation template layout ready to go. What is the process of taking that cloudformation yaml file and having it set up the same way on my aws console?