All pastes #777621 Raw Edit

Stuff

public c v1 · immutable
·published 2007-11-16 22:31 UTC
rendered paste body
int FILL_5 = 0;int FILL_3 = 1;int EMPTY_5 = 2;int EMPTY_3 = 3;int _3_TO_5 = 4;int _5_TO_3 = 5;struct State{    int move1;    int bucket5;    int bucket3;}state;int equals (state* s1, state* s2){        if (s1.bucket5==s2.bucket5 && s1.bucket3==s2.bucket3)        return 1;    else        return 0;}state* makeState(state* lastMove,int move){    	        if (move==FILL_5){	    state->move1 = move;            state->bucket5 = 5;            state->bucket3 =  lastmove->bucket3;	}	if (move==FILL_3){            state->move1 = move;            state->bucket5 = lastmove->bucket5;            state->bucket3 = 3;        }	if (move==EMPTY_5){	    state->move1 = move;            state->bucket5 = 0;            state->bucket3 = lastmove->bucket3;	}	if (move==EMPTY_3){	    state->move1 = move;            state->bucket5 = lastmove->bucket5;            state->bucket3 = 0;	}		if (move==_5_TO_3)		{			int total; 			total = lastMove->bucket5 + lastMove->bucket3;			state->move1 = move;			state->bucket5 = 0;			state->bucket3 = 0; 			if (total<=3)			{				state->bucket3 = total;			}			else			{				state->bucket3 = 3;				if (total-3<5){				    state->bucket5=total-3;				}				else 				    state->bucket5=5;							}			return state;		}		if (move==_3_TO_5)		{			int total;						total = lastMove->bucket5 + lastMove->bucket3;						state->move1 = move;			state->bucket5 = 0;			state->bucket3 = 0;			if (total<=5)			{				newMove->bucket5 = total;			}			else			{				state->bucket5 = 5;				if (total-5<3){				    state->bucket3=total-5;				}				else 				    state->bucket3=3;			}			return state;		}    return null;}