## Brief 

The setup can be briefly described as follows: 

- Input data - vectors with integer coordinates. (1003 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,...,71).  How to find - that is the challenge. 
- To apply move-vectors to state-vector -  just do numpy reindexing: 
```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-ihes-cube/data?select=puzzle_info.json). There are 18 moves, their names:  'f0', '-f0', 'f1', ... . Comments on moves names and their visualizations are in the last section.
- Submission: should contain the sequences of move names separated by dots for each sample, e.g. -f1.d0
- 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 both the mathematical and programming levels, we assume that each tile is assigned a unique index. In this setting, every state of the puzzle is represented as a permutation of these indices. The moves of the puzzle are also described by permutations, which specify how the positions of the indices are swapped after a move.

Within the scope of this competition, we further assume that each tile has a unique color (with the exception of the centers, which still have four attached indices). The puzzle is called to be "solved" if the **solution state** is achieved:
 
```python
solution_state = [0, 1, 2, 3, ..., 71]
```  

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

Submissions are evaluated on a set of **initial states** of the puzzle. There are 1003 states in the test set. The first one is Kontsevich's state describe above, the second and the third are related. While the other states organised by the simple principle:  The fourth  state is obtained by applying a single random move, the 5-th one -- by applying 2 constitutive random moves (independently from the previous sample), the 6-th 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.

## 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/cayleypy-ihes-cube/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/cayleypy-ihes-cube/data?select=puzzle_info.json)

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

**We invite all participants of this competition to find a solution for the Kontsevich cube. Please note that the *Kontsevich state* can be found in the competition data files test.csv and sample_submission.csv at index 0. We also invite you to solve two additional states move1 and move 2. These two configurations are indexed in sample_submission.csv at indices 1 and 2, respectively.**

| initial_state_id | path |
| :-------- | :-------: |
| 0 |d2.-f2.-d1.r2.-d1.f0.d0.r0.f2.f2.r0.-f0.r0.-f1.-d0.f1.-r0.-r0.-f2.-d1.f2.-d2.-f2.d2.d0.-r0.-d0.-d1.-f1.-f0.-f0.f1.-r0.f2.-d0.-r0.d0.-f2.d1.r0.-d1.-d1.-f0.d1.-f2.-r1.-f0.r1.f2.-f0.d0.-f0.-d0.f0.f0.f0.-r0.f0.r0.-f0.-r0.f0.f0.f0.d2.f0.-d2.f0.-r0.-d0.r0.d0.f0.-r0.-f0.r0.-f2.-r0.f0.r0.f2.-r0.f0.r0.-f0.d1.r0.-f0.-r0.f0.-d1.-f0.r0.f0.-r0.f0.-r0.-f0|
| 1 | r1.-d1.-r1.d2.r1.d1.-r1.-d2 |
| 2 | d2.-r0.r2.d2.d2.r0.-r2.d2.-r0.r2.d2.d2.r0.-r2 |
|...|...|
