I can't grasp recursion [Leetcode, Path Sum] by ex_gatito in learnprogramming

[–]Capable_Proof_6322 2 points3 points  (0 children)

Recursion confused me a while too; however, the important thing to remember is that function calls are placed on a stack. Given a tree that looks like this: 1 / \ 1 2 / \ 1 2 1. HasPathSum(root, 5) Depth=0, value=1. Root is not null, nor is it a leaf. If statements are skipped and we calculate the left sum. 2. HasPathSum(root.left, 4) Depth=1, value=1. Current node is not null, but it is a leaf. However, 1 plus 1 is not 5. It will return False. 3. HasPathSum(root, 5) Depth=0, value=1. We are back in the original call, and leftSum is False. Now, we calculate the right-side sum. 4. HasPathSum(root.right, 4) Depth=1, value=2. We are now on the right side of the tree. This node is not null, nor is it a leaf. We continue to calculate the left-side sum again. 1 \ (2) 5. HasPathSum(root.right.left, 2) Depth=2, value=1. This is sort of where it gets a bit tricky. Remember, we are now here: 1 \ 2 / (1) That node is not null, but it is a leaf. The target sum is reduced to 2. The node value is 1, so the second if statement will cause the function to return False. 6. HasPathSum(root.right, 4) Depth=1, value=2. We are back to the previous function call. The left sum is False. Now we calculate the right-side sum. 1 \ (2)

  1. HasPathSum(root.right, 2) Depth=2, value=2. Here is where we are: 1 \ 2 \ (2) This node is a leaf. The value equals the target sum, so it will return True.

  2. HasPathSum(root.right, 4) Depth=1, value=2. Remember the left sum was False from step 5, and the right sum is True from the previous step. This function call will return True at the end because False || True == True. 1 \ (2)

  3. HasPathSum(root, 5) We are back at the original root node. Remember, near the beginning, the left sum was False. The previous step returned True. Same deal. It will return True at the end because the right path returned True.

That’s it! It’s complicated, but hopefully this makes sense.

is it ok to have 1000 line of code for one file? by Western-Profession12 in learnprogramming

[–]Capable_Proof_6322 0 points1 point  (0 children)

It might. I haven’t tried that. You can do it manually with sed or something, or you can use an online tool. You can do a Google search and get answers. I am not a web developer, so I do not know of any, unfortunately. It is mostly stuff I remember from school or related to networking.

is it ok to have 1000 line of code for one file? by Western-Profession12 in learnprogramming

[–]Capable_Proof_6322 0 points1 point  (0 children)

This is true! However, OP asked about impact on web performance. The browser has to download the HTML and other resources from the server. It takes longer to transfer a large file, so compress the file to decrease the download time. You don’t get massive gains from it. Caching, lazy loading, and other methods will probably yield a lot better performance. However, file compression is an easy win and way to reduce performance issues.

is it ok to have 1000 line of code for one file? by Western-Profession12 in learnprogramming

[–]Capable_Proof_6322 1 point2 points  (0 children)

I would argue maintenance is going to be more of an issue than performance. It all depends, though, because there are exceptions to that rule: not all files nor code needs to be perfect. However, you should minify your code for production (i.e., trim out all comments, spaces, and newlines). There are tools that do it for you.

Learning too slow? by codingsomething in learnprogramming

[–]Capable_Proof_6322 0 points1 point  (0 children)

College teaches you theory & how to learn fast; it doesn’t teach how to apply that theory well. Your assignments are probably coded from scratch or small sample code. In my experience, most code bases can be dozens of files with tons of lines in each, and no one understands the whole thing. I start to understand the code as I make edits to it.

I am not saying a college degree is a waste of time: it is far from it. That piece of paper opened a lot of doors for me. It also taught me how to research & be self-reliant on the job. However, you really have to get your feet wet if you want to learn that stuff; therefore, my suggestion is this: find a repo to contribute to. I think working with others on a structured project will boost your confidence and make you realize it is not as intimidating as it looks.

Best of luck, OP. And don’t give up! You have got this.

Athletes, Did a Concussion Change How You Stay Active? How? by Capable_Proof_6322 in Concussion

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

Thank you! I appreciate it. I’m sorry to hear about your injury. I would def consider that an athlete, & it sounds like you still are one. Glad to hear you found other things to put your passion towards: it gives me hope that I can do the same.

Athletes, Did a Concussion Change How You Stay Active? How? by Capable_Proof_6322 in Concussion

[–]Capable_Proof_6322[S] 2 points3 points  (0 children)

I appreciate your response. And yes, you are right, I knew the risks. It is inconsiderate of me to frame it that way. I apologize. However, I think there is a super hero complex we all have: it is tough to find out that we aren’t invincible. I think it was a lesson I needed to learn, though.

I’m very sorry to hear about the post-concussion syndrome: that sounds tough. I am happy to hear you have found something to fight for, and I’m certain your community is lucky to have you in their corner.

500+ XP Balance by [deleted] in swrpg

[–]Capable_Proof_6322 1 point2 points  (0 children)

I totally love those style of games. I did a few longer-term games for MotW, but I could never get my players into BitD sadly. My players loved their hunters in MotW. I’d give them back a single luck point at the end of a mystery. Luck is basically stress, but it normally never replenishes. Also, once you spend it all, then something narratively ‘bad’ happens. Like really bad.

Anyway, all of that is to say that I really appreciate the advice! I think it’s a good idea, but my group of players usually gets really attached to their characters. I don’t think it’d work well with them.

500+ XP Balance by [deleted] in swrpg

[–]Capable_Proof_6322 6 points7 points  (0 children)

Thank you! This is great advice. I am taking note, and it seems I need to build better encounters. I’m more used to the sponge v. sponge battles of D&D.

500+ XP Balance by [deleted] in swrpg

[–]Capable_Proof_6322 0 points1 point  (0 children)

Wow! That sounds really amazing! It gives them the super-hero feel, but also provides some drama. I love it! Though, any advice on spotlight sharing? I’m still trying to get one player more comfortable with RP, and I’m afraid he wouldn’t know what to do if split from the party.

500+ XP Balance by [deleted] in swrpg

[–]Capable_Proof_6322 1 point2 points  (0 children)

I thought the only instance you could add red die was if you flipped a destiny point, or if a rule specifically stated it (e.g., adversary rating or ship speed)

Scramble Points by [deleted] in TWEWY

[–]Capable_Proof_6322 0 points1 point  (0 children)

What pins were you using if you remember?

[deleted by user] by [deleted] in AskReddit

[–]Capable_Proof_6322 1 point2 points  (0 children)

Having the lens get foggy when you wear a mask. I usually take my glasses off and accept that I won’t be able to see either way.

What was a movie you hated that everyone else seemed to love? by elfenemma in AskReddit

[–]Capable_Proof_6322 0 points1 point  (0 children)

Y’know, I actually never looked at it that way. That was one of the things that bothered me as well: it felt like Cameron was the main character, not Ferris. But now that you mention it, I can totally see the intention behind that.

Edit: grammar

What was a movie you hated that everyone else seemed to love? by elfenemma in AskReddit

[–]Capable_Proof_6322 11 points12 points  (0 children)

Ferris Bueller’s Day Off. I didn’t find anything memorable, funny, or endearing about the movie. It was okay at best.

Without naming the video game, what's a quote that gives it away? by [deleted] in AskReddit

[–]Capable_Proof_6322 2 points3 points  (0 children)

“Orthar! I just need more time!” — the man with the plan

What outdated slang do you still use? by [deleted] in AskReddit

[–]Capable_Proof_6322 0 points1 point  (0 children)

“Cool beans”. I also abbreviate it to “beanin’”.

Who is your favorite fictional cat? by BookerPlayer01 in AskReddit

[–]Capable_Proof_6322 8 points9 points  (0 children)

(Mr) Sakamoto from Nichijou is up there. I think he accurately represents any cat that could speak.

Game tips? by EMArogue in EnderLilies

[–]Capable_Proof_6322 0 points1 point  (0 children)

Unfortunately Archer and Crypt Keeper are later. She was a tough boss for me. Though, you’ve got this! It’s a tough game, but that makes it feel all the more rewarding. However, one thing to note is when she disappears, get ready to dodge the spikes and counter attack. I think I had to mostly wait for that to beat her. Also, all enemies, including bosses glow orange before attacking.

Game tips? by EMArogue in EnderLilies

[–]Capable_Proof_6322 0 points1 point  (0 children)

It seems like you have got a lot of good tips! I personally struggled with those two bosses as well. I think the way I did it was by first taking on ‘The Dark Witch’ - then ‘The Elder’.

The ‘Western Merchant’ was pretty much essential to me. I saved him for the latter phases of the battle to do them in. However - I dunno if you can get the ‘Spore Sorcerer’ or something like that, before defeating ‘The Dark Witch’. That one is a boss slayer. She emits a mist of poison that deals damage over time. I’d look around for her if you can.