Rating:

## :(

Unfortunately, my code is not well-formulated and may causes angry. It is divided into two separate files. I tried to merge this into an one file and enable to find a flag for a single execution but I don't have enough time. I'm just a poor graduate student. Please kindly understand this :(

## Step 0

Compared to ["baby version"](https://github.com/tsg-ut/tsg-live-ctf-6/tree/main/misc/fisher/dist), the frequency is changed(439.97Hz -> 440Hz)

Since `2205 * 440 % 44100 == 0`, `wave[i] = wave[i+2205]` for all i, which means that there are only 2205 of the unique values. Then priori approach seems not capable of this version. But by following below steps, this prob can be transformed as the system of the linear equations.

## Step 1.

generate `test.wav` file such that no shuffle / `wave[i] = np.sin(i * 440 / 44100 * (2 * np.pi))`

```
wave = np.empty(473 * 2000)
for i in range(len(wave)):
wave[i] = np.sin(i * 440 / 44100 * (2 * np.pi))
sf.write('test.wav', wave, 44100, 'PCM_24')
```

## Step 2.

Parse `test.wav`. find 2205 unique values. It is required to adjust the small error during convert & save wav files.

```
frames, samplerate = sf.read('./test.wav')
mapping = {}
T = 2205
for i in range(T):
mapping[frames[i]] = i
```

## Step 3.

Count the occurance of the each frequency of `result.wav`.

```
cnt = [0]*T
S2 = set()
for frame in frames2:
cnt[mapping[frame]] += 1
print(cnt)

'''
[444230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, ..., 229, 229, 229]
'''
```

## Step 4.

If `signals[i] == 0`, then `cnt[i*2000:(i+1)*2000] += 1`. This is the most important observation. But we have 473 unknown variables(`signals[i]`) and 441 known equations(You may wonder why the number of equation is 441, not 2205. But equation for `cnt[5k] = cnt[5k+1] = cnt[5k+2] = cnt[5k+3] = cnt[5k+4]`. So the number of equation is 2205/5 = 441).

Fortunately, we know the flag starts with `TSGCTF{`. So the number of the unknown variables are decreased 473 to 400. Then the system of the linear equations becomes solvable.

(eliminate `TSGCTF{` part)

```
v1 = string_to_signals('TSGCTF{') # len 73
L1 = [230, 230, 230, ..., 229, 229]
L2 = [L1[i] for i in range(0,len(L1),5)]
print(len(L1), len(L2))

for i in range(73):
if v1[i] == 0: continue
idx = i*400 % 441
for j in range(400):
L2[(idx+j)%441] -= 1

print(L2)
```

(solve linear equation)

```
from sage.all import *

B = vector([192, 192, 193, ... 191, 191, 192])
assert(len(B)==441)
M = [[0]*441 for i in range(441)]
for i in range(441):
for j in range(400):
M[i][(i+j)%441]=1

M = Matrix(ZZ, M)
A = M.solve_right(B)
print(A)

print(M*A==B)

# (0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, ... 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
```

## Step 5.

By using recovered `signals`, recover a flag. Beware of a re-indexing.

```
seq = (0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, ... 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
original = []
for i in range(34, 431):
idx = i*400%441
original.append(seq[idx])
print(signals_to_string(original))
```

## Codes

**chk.py**

```
import soundfile as sf
import numpy as np
from utils import signals_to_string, string_to_signals

def attempt2():
wave = np.empty(473 * 2000)
for i in range(len(wave)):
wave[i] = np.sin(i * 440 / 44100 * (2 * np.pi))
#sf.write('test.wav', wave, 44100, 'PCM_24')
frames, samplerate = sf.read('./test.wav')
mapping = {}
T = 2205
for i in range(T):
mapping[frames[i]] = i

print(frames[:T] == frames[T:2*T])

frames2, samplerate2 = sf.read('./result.wav')
cnt = [0]*T
S2 = set()
for frame in frames2:
cnt[mapping[frame]] += 1
print(cnt)

'''
[444230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230,
230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231,
231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231,
231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228,
228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226,
226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225,
225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226,
226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229,
229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227,
227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229,
229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229,
230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227,
227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228,
228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229,
229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230,
229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227,
227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225,
225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224,
224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228,
228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229]
'''

# 222 of zero, 251 of one

def attempt3():
frames, samplerate = sf.read('./test.wav')
mapping = {}
T = 2205
for i in range(T):
mapping[frames[i]] = i
v1 = string_to_signals('TSGCTF{') # len 73
L1 = [230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 229]
L2 = [L1[i] for i in range(0,len(L1),5)]
print(len(L1), len(L2))

for i in range(73):
if v1[i] == 0: continue
idx = i*400 % 441
for j in range(400):
L2[(idx+j)%441] -= 1

print(L2)

def attempt4():
seq = (0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 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, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
original = []
for i in range(34, 431):
idx = i*400%441
original.append(seq[idx])
print(signals_to_string(original))

#signals_to_string('1110001010101000100011101010101011100011100010111010001010111000100011101010101011100010101110100010111011101110111000101010001010101000100010111010001110111000101010101110001110100011101010101011100010101110001010101010001010101110111000101010001110101010101110001110111000111011101110111011100010111010001010100010001110101010101110001110101110100011101110111000111010100010001110101110111010111')
attempt4()
```

**linear.py**

```
from sage.all import *

B = vector([192, 192, 193, 193, 193, 193, 194, 193, 194, 193, 194, 193, 193, 193, 193, 194, 193, 194, 193, 193, 193, 193, 193, 192, 193, 193, 194, 193, 194, 193, 193, 192, 192, 193, 193, 193, 193, 194, 193, 194, 193, 194, 194, 193, 193, 192, 192, 192, 193, 192, 193, 192, 192, 192, 191, 191, 190, 190, 189, 190, 190, 191, 191, 191, 192, 191, 191, 191, 192, 192, 192, 192, 193, 193, 193, 193, 193, 193, 192, 192, 191, 191, 191, 191, 192, 191, 192, 191, 191, 190, 190, 189, 189, 189, 189, 189, 188, 189, 189, 190, 189, 190, 189, 190, 190, 189, 190, 189, 189, 188, 188, 188, 189, 189, 189, 189, 188, 189, 188, 189, 189, 189, 189, 189, 189, 188, 189, 188, 189, 188, 189, 189, 190, 190, 191, 191, 191, 191, 191, 192, 191, 192, 191, 192, 191, 191, 192, 191, 191, 190, 191, 190, 191, 190, 190, 190, 189, 189, 188, 189, 188, 189, 189, 190, 189, 189, 190, 189, 189, 189, 190, 190, 191, 190, 191, 190, 190, 191, 191, 191, 190, 191, 190, 191, 190, 191, 191, 190, 190, 190, 190, 190, 191, 190, 191, 190, 190, 191, 191, 191, 190, 191, 190, 191, 191, 191, 191, 191, 191, 191, 191, 190, 190, 190, 191, 191, 192, 192, 192, 193, 192, 193, 193, 194, 194, 194, 193, 193, 194, 194, 195, 195, 195, 194, 194, 193, 194, 194, 194, 195, 195, 195, 194, 194, 194, 194, 194, 194, 194, 194, 195, 194, 194, 193, 193, 193, 193, 192, 192, 192, 191, 192, 191, 191, 190, 190, 190, 190, 190, 189, 190, 189, 190, 189, 190, 190, 191, 190, 190, 190, 189, 190, 190, 191, 191, 191, 190, 191, 191, 190, 191, 190, 191, 191, 192, 191, 191, 190, 190, 190, 189, 190, 189, 190, 189, 190, 189, 190, 190, 190, 191, 191, 191, 190, 190, 189, 190, 189, 190, 190, 189, 190, 189, 190, 189, 190, 189, 190, 189, 189, 189, 188, 189, 188, 189, 188, 188, 187, 188, 188, 188, 188, 187, 188, 187, 187, 186, 186, 186, 187, 187, 186, 186, 186, 186, 186, 187, 186, 187, 186, 186, 187, 186, 187, 186, 186, 185, 185, 185, 185, 185, 185, 186, 185, 186, 186, 187, 187, 188, 187, 188, 188, 188, 189, 188, 189, 189, 189, 189, 189, 189, 189, 189, 188, 189, 189, 190, 190, 190, 189, 189, 189, 188, 189, 189, 190, 190, 191, 191, 191, 191, 191, 192, 192, 193, 192, 192, 191, 192, 191, 191, 190, 190, 191, 190, 191, 190, 191, 191, 192, 191, 191, 191, 191, 192, 191, 192, 191, 191, 191, 192])
assert(len(B)==441)
M = [[0]*441 for i in range(441)]
for i in range(441):
for j in range(400):
M[i][(i+j)%441]=1

M = Matrix(ZZ, M)
A = M.solve_right(B)
print(A)

print(M*A==B)

#(0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0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