// paradigmatest.txt

#include "code\paradigmus\paradigmus.txt"

//--------------------------------------------------------------------------------------------------
void main(){
	//namefunctionInput="paradigmaVovkKapustaKoza";
	//namefunctionInput="paradigmaOneBigAndTooSmoll";
	//namefunctionInput="paradigmaHoptoadJamps";
	//namefunctionInput="paradigmaXenoiskajaBashnia";
	namefunctionInput="max";

	f=getFunction("resultFunction");
	if(typeof(f)=="function"){
		f.run();
		}else{
		f=getFunction(namefunctionInput);
		f2=AnalizeParadigma(&f);
		if(typeof(f2)=="function"){
			trace(f2.exportText());//
			module=getThisModule();
			f2.setName("resultFunction");
			module.add(f2);
			}
		}
	getstring();
}



//--------------------------------------------------------------------------------------------------
/*
void paradigmaVovkKapustaKoza(){
	S={0,0,0,0};// Men,Vovk,Kapusta,Koza
	do{
		trace(S.export());
		ControlPset(S);
		P={};
		for(i=0;i<4;++i)if(S[i]==S[0])P.push(i);
		t=P[#];
		n=1-S[0];
		S[0]=S[t]=n;
		if(S[1]==S[3] && n!=S[1])OFF;
		if(S[2]==S[3] && n!=S[2])OFF;
		}while(S!={1,1,1,1});
	trace(S.export());
}


void paradigmaOneBigAndTooSmoll(){
	S={0,0,0,0};//Lodka,BigMen,SmolMen,SmolMen
	while(S!={1,1,1,1}){
		trace(S.export());
		ControlPset(S);
		Massa={0,2,1,1};
		P={0};
		sum=0;
		for(i=1;i<S.size();++i)if(S[i]==S[0])if(#%2){
			P.push(i);
			sum+=Massa[i];
			}
		if(sum>2 || sum==0)OFF;
		n=1-S[0];
		for(i=0;i<P.size();++i)S[P[i]]=n;
		}
	trace(S.export());
}


void paradigmaHoptoadJamps(){
	S={1,1,1,0,2,2,2};
	while(S!={2,2,2,0,1,1,1}){
		trace(S.export());
		ControlPset(S);
		P={};
		for(i=0;i<S.size();++i){
			if(S[i]==1){
				if(S.size()>i+1)if(S[i+1]==0)P.push({i,i+1});
				if(S.size()>i+2)if(S[i+2]==0)P.push({i,i+2});
				}
			if(S[i]==2){
				if(i-1>=0)if(S[i-1]==0)P.push({i,i-1});
				if(i-2>=0)if(S[i-2]==0)P.push({i,i-2});
				}
			}
		if(P.empty())OFF;
		X=P[#];
		S[X[1]]=S[X[0]];
		S[X[0]]=0;
		}
	trace(S.export());
}



void paradigmaXenoiskajaBashnia(){
	S={{3,2,1},{},{}};
	while(S!={{},{3,2,1},{}}){
		trace(S.export());
		ControlPset(S);
		pairs={};
		for(i=0;i<3;++i)if(!S[i].empty()){
			UPiz=S[i].end();
			for(j=0;j<3;++j)if(j!=i){
				UPto=0;
				if(S[j].size())UPto=S[j].end();
				if(UPto==0 || UPto>UPiz)pairs.push({i,j});
				}
			}
		pair=pairs[#];
		X=S[pair[0]].pop();
		S[pair[1]].push(X);
		}
	trace(S.export());
}
*/

void max(){
	S={1,7,12,3,8};
	do{
		ok=0;
		t=S[#];
		ControlPset(t);
		for(i=0;i<S.size();++i)if(S[i]>t)ok=1;
		}while(ok);
	trace(t);
}



// paradigmatest.txt	:-|