# The pirate world's rules of distribution

## Jelly, ~~11~~ 10 bytes

```
R%2ḊµSȷ2_;
```

Try it online! or verify all test cases at once.

### How it works

For input **n**, the task boils down to creating the list **x, 0, 1, 0, …** of length **n** whose sum is **100**.

```
R%2ḊµSȷ2_; Main link. Input: n
R Yield [1, 2, ..., n].
%2 Replace each integer by its parity. Yields [1, 0, 1, 0, ...].
Ḋ Dequeue; remove the first 1. This yields the list a = [0, 1, ...].
µ Begin a new, monadic link. Argument: a
S Compute the sum of a.
ȷ2_ Subtract the sum from 100. (ȷ2 is 1e2 in Python syntax)
; Prepend the difference to a.
```

### Python, 33 bytes

```
lambda n:([-n/2+101]+[0,1]*n)[:n]
```

Computes the first value, appends some `0, 1, 0, 1...`

, truncates to length `n`

.

Note that `-n/2+101`

can't be shortened to `101-n/2`

because unary and binary `-`

have different precedence: the former is parsed as `(-n)/2`

and the latter as `101-(n/2)`

.

Recursion was much longer (45):

```
f=lambda n,i=100:1/n*[i]or f(n-1,i-n%2)+[n%2]
```

## MATL, 12 bytes

```
:2\ts_101+l(
```

This uses current version (9.2.2) of the language/compiler, which is earlier than this challenge.

### Example

```
>> matl :2\ts_101+l(
> 5
98 0 1 0 1
```

### Explanation

```
: % implicitly input number "n". Generate vector [1, 2, ..., n]
2\ % modulo 2. Gives [1, 0, 1, ...]
ts % duplicate and compute sum
_101+ % negate and add 101
l( % assign that to first entry of [1, 0, 1, ...] vector. Implicitly display
```