All pastes #200367 Raw Edit

Untitled

public text v1 · immutable
#200367 ·published 2006-10-13 03:23 UTC
rendered paste body
:begin
Start with pile U
X = (int) U/4;
Divide U into A1, A2, B1, and B2, into four parts of X coins
If count(U) < 4 goto END;
If A1 == A2 {
	If B1 == B2 {
		Shuffle(U);
		Goto begin;
	} else {
		U = (B1 + B2 + X);
	}
} else {
	U = A1 + A2 + x;
}
Goto Begin
:END
If count(U) == 2 {
        return U1, U2;
} else {
        if U1 == U2 {
                if U1 == U3 {
                       return U1,U2;
                } else {
                       return U2,U3
                }
        } else {
               return U1,U3
        }
}