Task
Given an array of positive integers, replace each element with the parity of the sum of the other elements. The array is guaranteed to have at least 2 elements.
Definition
- Parity: whether a number is odd or even.
Example
For the array [1,2,3,1]
:
- Replace
1
with the parity of2+3+1
, i.e.even
. - Replace
2
with the parity of1+3+1
, i.e.odd
. - Replace
3
with the parity of1+2+1
, i.e.even
. - Replace
1
with the parity of1+2+3
, i.e.even
.
Output: [even, odd, even, even]
Input
An array of positive integer.
You may take it as a proper array, or as a linefeed-separated string of positive integers.
You may assume that the array and the values inside are within the handling capability of your language.
Output
An array of two consistent values, one representing odd
, one representing even
.
You may output it as a linefeed-separated string of the two values.
Testcases
Inputs:
[1, 2, 3, 1]
[1, 2, 3, 2, 1]
[2, 2]
[100, 1001]
Outputs:
[even, odd, even, even]
[even, odd, even, odd, even]
[even, even]
[odd, even]
Note: you may choose other consistent values other than odd
and even
.
Scoring
This is code-golf. Shortest answer in bytes wins.
Standard loophole applies.