
#include <stdio.h>
#define HEIGHT	15
/* Data type for rod */
typedef struct
{
	int display_ID; /* rod-ID to display */
	int discs; /* number of discs currently stored on this rod */
	int discarr[HEIGHT]; /* array of discs currently stored on this rod */
}rod_t;

/* global declaration: 3 rods */
rod_t rod1, rod2, rod3;

/* helper function: prints content of supplied rod */
void print_rod(rod_t rod)
{
	int i;
	printf("rod: %d: |",rod.display_ID);
	for(i=0; i < HEIGHT; i++)
	{
		if( i < rod.discs)
		{
			printf("%2d|",rod.discarr[i]);
		}else
		{
			printf("==|");
		}
	}
	printf("\n");
}

/* implement function that moves disc from source to destination here */

/* implement the recursive algorithm here */
void hanoi(int num_discs, rod_t *source_rod, rod_t *intermediate_rod, rod_t *destination_rod)
{
	
}
/* inizialize variables */
void hanoi_init(rod_t *first, rod_t *second, rod_t *third, int discs)
{
	(*first).discs = discs;
	int i;
	for (i=0; i < discs; i++)
	{
		(*first).discarr[i] = discs-i;
	}
	(*first).display_ID=0;
	(*second).discs = 0;
	(*second).display_ID=1;
	(*third).discs = 0;
	(*third).display_ID=2;
}
/* run this function to start the application */
int run(int size)
{
	if (size > HEIGHT) return -1;
	printf("Start of main program: Towers of Hanoi\n");

	hanoi_init(&rod1,&rod2,&rod3,size);
	print_rod(rod1);
	print_rod(rod2);
	print_rod(rod3);
	
	hanoi(size, &rod1, &rod2, &rod3);
	return 1;
}
int main(int argc, char *argv[])
{
	if (run(3)) 
		return 1;
	else
	return -1;
} 

