« first day (905 days earlier)      last day (32 days later) » 

4:52 AM
@Learner Are you allowed zeros for the Ai values?
It says the Ai have to be positive integers so maybe that means they cannot be zero.
 
5:06 AM
Oops, yes sir :-(
Thinking again
 
@Learner If the sum is odd it can't be done
 
Yes
 
If the sum is even and N is even it's easy because you can split the sum into pairs of equal numbers.
The only hard bit is if N is odd.
Then you need to split off three numbers that XOR to zero e.g. 1, 2 and 3
That leaves you with N-3 (which is even) numbers to sum to S-6
 
@JohnRennie And sir also if N>S
 
True
 

« first day (905 days earlier)      last day (32 days later) »