## Brief 

The setup can be briefly described as follows: 

- Input data - vectors with integer coordinates. (1000 vectors)
- Solution -   for each input vector -  find sequences of "moves" such that applying it to the input vector one gets the fully sorted vector: (0,1,2,3,...,87).  How to find - that is the challenge. 
- To apply move-vectors to state-vector -  just do numpy reindexing ([example notebook](https://www.kaggle.com/code/alexandervc/cayleypy-professor-tetraminx-introduction)): 
```python
state_vector[ move1_vector][move2_vector]...[moveN_vector]
```  
- Move names and corresponding vectors are stored in [puzzle_info.json](https://www.kaggle.com/competitions/CayleyPy-Professor-Tetraminx-Solve-Optimally/data?select=puzzle_info.json). There are 24 moves, their names:  '2BL', '-2BL', '3BL', ... . Comments on moves names and their visualisations are in the last section.
- Submission: should contain the sequences of move names separated by dots for each sample, e.g. 2BL.-4D
- Evaluation: sum of the lengths of solutions (how many moves used in total - i.e.  first count number of moves for each test sample and then sum over all 1000 samples).

## Details

Here we repeat with more details what was briefly described above.

### States and moves  are integer vectors  (permutations)

To work with such puzzles on mathematical and programming levels, we assume each tile to be indexed with a unique number. In this setting each state of the puzzle is a permutation of the indices. The moves of the puzzle are permutations as well, which tell how the locations of the indices are swapped after the move.

In the scope of this competition we assume each tile to have a unique color. The puzzle is called to be "solved" if the **solution state** is achieved:
 
```python
solution_state = [0, 1, 2, 3, ..., 87]
```  
The full set of the moves can be found in [puzzle_info.json](https://www.kaggle.com/competitions/professor-tetraminx-pathfinding/data?select=puzzle_info.json).

### Input data - 1000 integer vectors ("initial states" - permutations) 

Submissions are evaluated on a set of **initial states** of the puzzle. There are 1000 states in the test set. The first state is obtained by applying a single random move, the second one -- by applying 2 constitutive random moves (independently from the previous sample), the third one -- by 3 moves and so on up to 1000. The moves are  sampled uniformly from the set of all possible moves.

For each **intial state** the participant needs to provide a set of moves to get to the **solution state**. If there is a path in submission which doesn't lead to the **solution state**, the whole submission is considered invalid.

### Evaluation: score = number of moves

For a valid submission the final score are the sums of the lengths of all paths:

$$ score = \sum_{path \in Test}\mathrm{len}(path) $$

The lower the score the better the result is.

The paths used for generation the samples are provided in [sample_submission.csv](https://www.kaggle.com/competitions/professor-tetraminx-pathfinding/data?select=sample_submission.csv). These paths are highly non-optimal, however they can be used to get a valid submission.
 
E.g. sample submission score is 50500 - sum of all numbers from 1 to 1000 - the lengths of highly non-optimal solutions used for data generation. 

## Submission File
For each initial_state_id in the test set, you need to generate a path from the **initial state**(from [test.csv](https://www.kaggle.com/competitions/professor-tetraminx-pathfinding/data?select=test.csv file) to the **solution state** . 

The path is a string of dot-separated generator names. The generator are assumed to be applied to the **initial state** to the **solution state** starting from left to right.  The generators and the solution state can be found in [puzzle_info.json](https://www.kaggle.com/competitions/professor-tetraminx-pathfinding/data?select=puzzle_info.json)

Make sure that the values in  **initial_state_id** column are ordered from 0 to 1000.


| initial_state_id | path |
| :-------- | :-------: |
| 0 | -2D |
| 1 | 2BL.-4D |
| 2 | -2BR.2F.2BL|
|...|...|
