#include "pile_type.h"
#include "pile.h"
#include "hanoi.h"
#include <stdio.h>
#include <sys/time.h>

#define N 30

int main(int argc, char** argv) {
    PILE src = InitPile();
    PILE interm = InitPile();
    PILE dest = InitPile();

    for(int i = N; i > 0; i--) {
        src = Empiler(src, i);
    }

    struct timeval ta, tb;

    printf("-- Avant --\n");
    printf("Source : ");
    AfficherPile(src);
    printf("Interm.: ");
    AfficherPile(interm);
    printf("Dest.  : ");
    AfficherPile(dest);

    gettimeofday(&ta,0);
    hanoi(&src, &interm, &dest, N);
    gettimeofday(&tb,0);

    printf("-- Apres --\n");
    printf("Source : ");
    AfficherPile(src);
    printf("Interm.: ");
    AfficherPile(interm);
    printf("Dest.  : ");
    AfficherPile(dest);

    printf("\nTemps (micro-sec) = %ld\n",
     1000000*(tb.tv_sec-ta.tv_sec) + tb.tv_usec-ta.tv_usec);

}
