I have written some code (a long one) where I have multiple functions which return a boolean value i.e. either true or false. One of them (one of the boolean functions) has a lot of if statements in it, one below the other, where each statement simply returns true if the condition evaluates to true, otherwise it does nothing (there is no else statement after any if statement). And at the end there is return false statement (in case none of the if statements evaluate to true). Now here is the problem, the function executes most of the if statements correctly but doesn’t execute the if statements towards the end (six of them) and doesn’t execute the return false statement once every if statement has evaluated to false. What could be the possible reasons for it? Anyone please help. I have been using the debugger to solve this problem, but nothing seems to work.
Probably need to see the code for this
I would have posted the code. But the problem is that it is a solution (possibly a solution for now as I am not sure if it will get an AC) for one of the problems from an ongoing contest. So I can’t post it.
Though it would be helpful if you could point out any common issues that result in this type of behavior.
In that case, the general answer is that your logic/code is probably wrong and one or more of the if-statements isn’t what you expect it to be.
Anything more specific is probably at least borderline cheating.
No, I am not talking about the logic here. The only problem that I am facing for now, is that the function doesn’t even step in those if statements neither does it step in that return statement, whereas according to what I know till now, when we use multiple if statements then all of them are checked once, which is not the case over here. Any possible reasons for this?
If the function doesn’t check the if-statement, then it’s returning before it gets there
As far as borderline cheating is concerned, IMHO I haven’t asked about any specific details which are specific to any problem.
I don’t really know how the rules work here
; clarification posts are flagged and removed even though it literally says on the contest page that asking for clarifications is allowed, so I’m not sure what classifies as cheating
Before someone swoops in, I’m going to correct myself and say I misread lol
Maybe I should look more carefully. Thanks for the help
I can imagine 2:
- you are wrong
- YOU ARE WRONG (UPPERCASE)
Not your fault. I appreciate your help
Ha Ha Ha
I am partly sure about that seeing the number of WA submissions I have made for that problem.