int helper(int *battlefield, int columns, int n)
{
	int i;
	if (columns >= n)
		return 1;

	for (i = 0; i < n; i++)
	{
		if (ispossible(battlefield, i, columns, n))
		{
			battlefield[i*n + columns] = 1;
			if (helper(battlefield, columns + 1,n))
				return 1;
			battlefield[i*n + columns] = 0;
		}
	}
	return 0;
}
void addpart(int n, int f, int t, shared_ptr<List> nodeList)
{

	//Contianer for deleted nodes
	vector<int *> dNodes(100);

	int i,j,it;
	int s=0;
	int ns =0;
	for(i=f;i<=t;i++)
	{
		a = copyNode(possible[i]);
		delete [] p[n+1];
		p[n+1] = a; //Transfering possible[i] to p[n+1]
		a = NULL;
		ns = 0;
		for(int l=dim-1;l>=0;l--)//Decrementing each coordinate
		{
			d = copyNode(possible[i]);
			d[l]--;
			if(nodeList->delete_node(d))
			{
				dNodes[ns] = d;
				ns++;
			}
			else
			{
				delete [] d;
			}
		}
	nodeList->insert_tail(copyNode(possible[i]));
	res[n+1]++;
	sum[n+1] += nodeList->listSize();
		if(n==num-1)
		{
			//Partition has been generated
			for(it=0;it<ns;it++)
			{
				nodeList->insert_tail(copyNode(dNodes[it]));
			}
			nodeList->delete_node(possible[i]);
			continue;
		}
		for(j=dim-1;j>=0;j--)//Increment each coordinate
		{
			a = copyNode(possible[i]);
			a[j]++;
			if(ispossible(p, a, n+1))//Check if node is possible
			{
				s++;
				delete [] possible[s+t];
				possible[s+t] = a;//Add to possible
				a = NULL;
			}
			else
			{
				delete []a;
			}
		}
		addpart(n+1, i+1, s+t, nodeList);//Recursive call
		s = 0;
		for(it=0;it<ns;it++)
		{
			nodeList->insert_tail(copyNode(dNodes[it]));
		}
		nodeList->delete_node(possible[i]);
		dNodes.clear();
	}
}