Contents
Your task is to develop a system for reassembly of shredded documents. Given slices of a document cut along the vertical axis, your system is to output the permutation of input slices that correctly reassembles the document.
All strips will be of the same width and height. You are guaranteed that all strips are the right way up.
You've done the other challenges, so you should know the drill:
# Build your container
docker build -t TEAM_ID-surprise:TAG .
# Run your container
docker run -p 5005:5005 --gpus all -d TEAM_ID-surprise:TAG
# Test your container
pip install -r requirements-dev.txt
python3 test.py
# Submit
./submit-surprise.sh TEAM_ID-surprise:TAGThe input is sent via a POST request to the /surprise route on port 5005. It is a JSON document structured as such:
{
"instances": [
{
"key": 0,
"slices": ["base64_encoded_slice", ...]
},
...
]
}Each object in the instances list corresponds to a single shredded document. Each string in the slices list contains the base64-encoded bytes of a single slice of that document represented as a JPEG image.
The length of the instances list is variable.
Your route handler function must return a dict with this structure:
{
"predictions": [
[p11, p12, ..., p1s],
[p21, p22, ..., p2s],
...
]
}where:
-
$s$ is the number of slices in each document, and -
$[p_{i1}, p_{i2}, \dots, p_{is}]$ is the predicted permutation of input slices that correctly reassembles the$i$ -th document, leftmost slice first.
For instance, if you're given a single document in three slices, and you think that:
- the first slice should go in the middle
- the second slice should go on the left
- the third slice should go on the right
then you would return:
{
"predictions": [
[1, 0, 2]
]
}The predictions must be the prediction corresponding to the instances for all predictions must equal that of instances.
- Predictions that contain long runs of correctly assembled slices will score better.
- Predictions that contain several short runs will score worse.
- If your prediction is not a permutation of
$[0, 1, \dots, s-1]$ , your score will be zero.
First we check that your prediction is a permutation of
Let
Your score is then given by
The highest-scoring run-length list is
The lowest-scoring run-length list is