Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 29 bytes

JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

###How?

How?

We start with the bitmask \$m=101_2=5_{10}\$ and right-shift it by one position for each odd value in the input array. The final result is given by the parity of \$m\$.

#JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

###How?

We start with the bitmask \$m=101_2=5_{10}\$ and right-shift it by one position for each odd value in the input array. The final result is given by the parity of \$m\$.

JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

How?

We start with the bitmask \$m=101_2=5_{10}\$ and right-shift it by one position for each odd value in the input array. The final result is given by the parity of \$m\$.

added an explanation
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

#JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

###How?

We start with the bitmask \$m=101_2=5_{10}\$ and right-shift it by one position for each odd value in the input array. The final result is given by the parity of \$m\$.

#JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

#JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!

###How?

We start with the bitmask \$m=101_2=5_{10}\$ and right-shift it by one position for each odd value in the input array. The final result is given by the parity of \$m\$.

Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

#JavaScript (ES6), 29 bytes

a=>a.map(x=>m>>=x&1,m=5)&&m&1

Try it online!