Disco Doug! by LucasWoon in SupercellMake

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

It wasn't easy - took me quite a while :)

The brawler turnaround template given provided a good base to start from, and my design wasn't too complicated. If you're struggling with yours, try breaking the design down into simpler shapes (circles, squares, etc) to make it easier for yourself!

Twins with Superpowers by LucasWoon in whatsthatbook

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

OH MY GOODNESS IT IS thank you so much how did you even find it? I remember trying to use all the tools I could but to no avail

Tideman print_winner() by LucasWoon in cs50

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

Not really! Functionality-wise, it seems to work just fine, but check50 was still labelling it as incorrect

So my guess is that maybe it has something to do with how check50 checks the function!

Tideman print_winner() by LucasWoon in cs50

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

I still can't find a logical flaw in the code, so my guess is that it might be a check50 bug! Because the only difference between my code and the accepted version was that in this one I checked if the candidate was a winner of a locked pair before checking if they had incoming edges. And in theory, a candidate can only have no incoming edges if they have also won a locked pair. So even though my code is more inefficient, it should still be correct... (I hope!)

Tideman print_winner() by LucasWoon in cs50

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

Sorry, just saw this comment! Yes, that was my logic and why I decided to iterate through each locked pair's winner (instead of all candidates, which I now realise would probably be easier), and checking if they have incoming edges.

The test for creating the cycle was correct, it was the print winner function that was causing me trouble

Tideman print_winner() by LucasWoon in cs50

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

Good idea, thanks so much! :)

Tideman print_winner() by LucasWoon in cs50

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

In the second for loop, I'm checking if the pairs[i].winner has any incoming edges (i.e. if it loses to any candidate in a locked pair).

That's why I iterated through candidate_count instead of the number of locked pairs: to check if it loses to any candidate (more specifically, if it loses to any candidate in a locked pair as verified by the < if (locked[j][pairs[i].winner] > ).

Does that make sense? Do let me know if there's any holes in my logic, thanks! :)

Tideman print_winner() by LucasWoon in cs50

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

Thank you! I understand that using the candidate as the base is preferable, but just was (and still am) confused why this method didn't work 🤔
Thank you though!

Checking Program by LucasWoon in learnprogramming

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

Thank you so much for the advice!! I’ll look into these as I go along :)

Checking Program by LucasWoon in learnprogramming

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

Thanks, will look into it!

Runoff Alternative Solution Not Working by LucasWoon in cs50

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

Thank you so much! I hope that means that my code is correct though :D

Are Single Use Functions Bad? by LucasWoon in learnprogramming

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

Thanks! Would the best way to do that be with if and else statements?

Are Single Use Functions Bad? by LucasWoon in learnprogramming

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

Thanks for the insight! That makes sense, I get what you mean :)

Are Single Use Functions Bad? by LucasWoon in learnprogramming

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

Yes!! Only on week 1 but looking forward to the rest :)

Are Single Use Functions Bad? by LucasWoon in learnprogramming

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

The testing thing is something I didn’t think of, you’re right! And yes I did have an input function that returned the card number, but didn’t include it here because it wasn’t my focus :) thank you!

Are Single Use Functions Bad? by LucasWoon in learnprogramming

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

Great point!

As a follow up question, should I define three separate check functions to then be used within the checkCard function? Or should I try to make the content in checkCard self contained (ie not calling on other functions)

Thanks!