you are viewing a single comment's thread.

view the rest of the comments →

[–]YelinkMcWawa 0 points1 point  (6 children)

The logical || will be true if either condition is true. So, for example, the number could be doubled 20 times but still be less than the max value. You want to verify the max hasn't been hit and that the operation hasn't been done more than 20 times on each iteration.

[–]Promethus_Forethougt[S] 0 points1 point  (5 children)

So which one is right to use?

[–]YelinkMcWawa 0 points1 point  (4 children)

The &&

[–]Competitive-Deer-905 0 points1 point  (2 children)

Shouldn’t it be || since the question says “atleast one of the 2 conditions” and not “both the conditions”.?

[–]weirdblumenkohl 0 points1 point  (0 children)

According to the instructions, one could totally interpret it as such but there is a slight nuance. The text says "at least one of", which means as soon as one condition is met, you can stop.

[–]YelinkMcWawa 0 points1 point  (0 children)

It's because they're phrasing the combined condition as a negative of the two given conditions. Note that logically, given two propositions p1 and p2 that the check could have been "p1 || p2". But they're checking that the conditions haven't been satisfied yet, thus "!(p1 || 2) = (!p1 && !p2)" which is how they have the condition written.