codebrrr
Joined 2 years ago
Karma
13
Submissions
4
Member since
Dec 29
Joined 2 years ago
> You can use arithmetics to go branchless.
if (a[i] > 0) {
cnt++;
}
> Rewriting using arithmetic takes advantage of the fact that the expression a[i] > 0 has an arithmetic value 1 if true and 0 if false. So the whole expression can be rewritten as: cnt += a[i]
I like to call them clothes printers.