r/code • • Aug 15 '22

What's the point of embedding increasing into for statement?

Post image
9 Upvotes

3 comments sorted by

3

u/StochasticTinkr Aug 15 '22

If you find any that is not increasing, you don’t need to check any more.

2

u/chris17453 Aug 16 '22

I can see this written by somebody who sort sort of understands what's going on. And it's just like fucker I'm using flags.

Also it feels like this belongs in a SVN repository... On an old Solaris spark... under someone's desk.. in a fallout shelter.. in brazil... in 1978

1

u/dustractor Aug 16 '22

assuming you mean the second for loop, if the i-th value in a is greater than then next (i+1) value in a, then set increasing to false so it will break out of the next iteration of the for loop