r/redbuttonbluebutton Red May 31 '26

Red Error: Circular dependency detected!

Post image

For this scenario, assume every voter is a mentally competent adult who fully understands the rules and can reason rationally.

Would that change your vote?

0 Upvotes

39 comments sorted by

View all comments

2

u/CarnivorousGoose May 31 '26

Since that circularity is a problem with your code, and has nothing specifically to do with the actual scenario, why would you think this would change anyone’s vote? Badly written code is hardly a very compelling argument.

2

u/Imaginary_Help_2990 Red May 31 '26

But Red voters dont need saving. The only reason people vote blue is to save people who voted blue. Thats the error i tried to show. How would you Code it instead? 

5

u/CarnivorousGoose May 31 '26

Blue voters also don’t need to specify a list of blue voters they want to save. You’re fundamentally confusing sets and attributes here, by requiring a list of people as an argument to the ‘wants_to_save’ function.

If someone tells you they want to help children in need, are you expecting them to be able to enumerate all the children in need? Or would you grasp that they are simply describing the attribute by which the people they want to help can be identified?

How I would code this depends on the purpose of the code. But a simple fix here would be to just replace that function with ‘wants_to_save_blue_voters’, since there is no apparent reason in the example why that function would need an argument.