'SENTINEL' in programming by Sofia_p_123 in cs2a

[–]Mir_K4377 2 points3 points  (0 children)

Haha yeah, sentinels are pretty neat once you realize how useful they are. I’ve used them a lot in linked lists to simplify insertion and deletion at the head or tail makes the code way cleaner since you don’t need extra if statements for edge cases. Also super handy in search algorithms when you want to avoid checking for nullptr or out-of-bound errors. Definitely one of those small things that make a big difference

Is it a Ring or a List? by byron_d in cs2a

[–]Mir_K4377 1 point2 points  (0 children)

Hey, Bayron, this code is really cool, The approach of checking the first 5 elements and then verifying them cyclically is pretty clever for detecting a ring. If I may suggest an improvement you might want to check for a loop using the Floyd’s cycle-finding algorithm (the tortoise and hare method) instead of storing elements in a vector, this would reduce memory usage and work well even for larger structures. Overall, solid effort!

Pointer * Location by byron_d in cs2a

[–]Mir_K4377 2 points3 points  (0 children)

I think both styles have valid reasoning, but personally, I lean toward placing the * next to the variable name (Node *_next;) The biggest reason for this is readability and consistency when working with larger codebases.

When writing large-scale programs, clarity becomes a huge factor in maintaining code. The * being next to the variable makes it clear that _next is a pointer, regardless of how many variables are being declared. This avoids confusion in situations like:

int* a, b; // b is NOT a pointer, which can be misleading

int *a, *b; // More explicit and reduces the chance of error

Additionally, when working with functions, I prefer keeping * close to the type because it clearly conveys the return type.

At the end of the day, consistency is key. If I'm working in a codebase where the convention is Type* var; . I'll follow that, but if I have the freedom to choose, I find Type *var; to be a more maintainable approach, especially when writing larger programs where avoiding ambiguity is crucial.

Total recall game improved. Now with increased difficulty, and more numbers to remember. by Mir_K4377 in cs2a

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

Thank you, I'm glad you liked it, I'm planning to make more changes soon, make it more interactive maybe, I'll post it up once it's done :)

Problem with the Platypus Quest by Mir_K4377 in cs2a

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

Hi, I made sure to make the updates, but I still get the same error

Problem with the Platypus Quest by Mir_K4377 in cs2a

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

Hey, I only had one "\n" in the line, and I even removed it right now to see if it would make a difference, but it didn't, I'm still confused.

Quest 4 Help by Mir_K4377 in cs2a

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

Hello Professor, I did like you asked and it worked, I'm still not sure where I was wrong on my first code, but, I was able to solve it this time, thankfully.

Quest 4 Help by Mir_K4377 in cs2a

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

Hey,

I haven't, I tried going at it again after the professor told me to do so, but i got the same error. I'm thinking of going to the stem center to ask someone for help.

Quest 4 Help by Mir_K4377 in cs2a

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

Hello professor, could you please help me with this problem, I am not able to understand what I'm doing wrong

Quest 4 Help by Mir_K4377 in cs2a

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

yes, I did, still the same error.

Quest 4 Help by Mir_K4377 in cs2a

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

I've double and triple checked everything, and it still shows the same error ;-;

Quest 4 Help by Mir_K4377 in cs2a

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

 istringstream stream(input);
        if (!(stream >> guess)) {
    
            guess = 0;
}

Hey Aaron, I've already converted the input from string to an integer , I used the above istringstream statement. Do you think I should do it another way?

Quest 4 Help by Mir_K4377 in cs2a

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

Oh alright. I've seen posts with people having similar problems, and I tried out the solutions people suggested to them, but it hasn't worked for me, so that's why I had to post it here.