/******  Backtracking dominos ******/

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

/* Domino */
struct domino_s {
    int x; // valeur de gauche
    int y; // valeur de droite
};

typedef struct domino_s Domino;

/* Maillon */
struct element_s {
    Domino d;
    struct element_s* suiv;
};

typedef struct element_s element;

/* Chaine */
typedef element* chaine;


/**** Partie 1 ****/

/* Affiche les dominos d'une liste */
void afficheDominos(element* L){
    element* l = L;
    while (l != NULL) {
        printf("(%d,%d)-", l->d.x, l->d.y);
        l = l->suiv;
    }
    printf("\n");
}

/* Alloue un maillon dans le tas, et l'ajoute en tĂȘte de liste */
element* ajouteTete(element* L, Domino d){
    element* elt = (element*) malloc(sizeof(element));
    elt->d = d; elt->suiv = L;
    return elt;
}





int main(){
    printf("Backtracking - Dominos\n");

    /*NB : initialiseur de structure + initialiseur de tableau */
    Domino jeu0[3] = {{.x = 1, .y = 0}, {.x = 1, .y = 1}, {.x = 0, .y = 0}};  // faisable
    bool libre0[3] = {true, true, true};

    Domino jeu1[2] = {{.x = 2, .y = 1}, {.x = 0, .y = 1}};  // faisable avec rotation
    bool libre1[2] = {true, true};

    Domino jeu2[5] = {{.x = 5, .y = 4}, {.x = 4, .y = 0}, 
    {.x = 0, .y = 1}, {.x = 3, .y = 2}, {.x = 3, .y = 5}};  
    bool libre2[5] = {true, true, true, true, true}; // faisable avec rotation

    Domino jeu3[5] = {{.x = 0, .y = 0}, {.x = 0, .y = 1}, 
    {.x = 1, .y = 4}, {.x = 1, .y = 2}, {.x = 2, .y = 2}}; // infaisable
    bool libre3[5] = {true, true, true, true, true};

    Domino jeu4[6] = {{.x = 1, .y = 2}, {.x = 1, .y = 3},
    {.x = 1, .y = 1}, {.x = 2, .y = 3}, {.x = 2, .y = 4}, {.x = 3, .y = 4}};
    bool libre4[6] = {true, true, true, true, true, true};

    Domino jeu5[10] = {
    {.x = 0, .y = 1}, {.x = 0, .y = 2}, {.x = 0, .y = 3}, {.x = 0, .y = 4}, 
    {.x = 1, .y = 2}, {.x = 1, .y = 3}, {.x = 1, .y = 4},
    {.x = 2, .y = 3}, {.x = 2, .y = 4},
    {.x = 3, .y = 4}};
    bool libre5[10] = {true, true, true, true, true, true, true, true, true, true};

    Domino jeu6[15] = {
    {.x = 0, .y = 0}, {.x = 0, .y = 1}, {.x = 0, .y = 2}, {.x = 0, .y = 3}, {.x = 0, .y = 4}, 
    {.x = 1, .y = 1}, {.x = 1, .y = 2}, {.x = 1, .y = 3}, {.x = 1, .y = 4},
    {.x = 2, .y = 2}, {.x = 2, .y = 3}, {.x = 2, .y = 4},
    {.x = 3, .y = 3}, {.x = 3, .y = 4},
    {.x = 4, .y = 4}};
    bool libre6[15] = {true, true, true, true, true, true, true, true, true, true, 
                       true, true, true, true, true};

    return 0;
}