'\begin{verbatim} 'declare function and variables DECLARE FUNCTION CountEq! (a!, b!, c!, d!, e!) 'prepare screen CLS PRINT "Listing four of a kind outcomes in Yahtzee..." '*** go through all cases FOR a = 1 TO 6: FOR b = 1 TO 6: FOR c = 1 TO 6: FOR d = 1 TO 6: FOR e = 1 TO 6 IF CountEq(a + 0, b + 0, c + 0, d + 0, e + 0) = 4 THEN PRINT a; b; c; d; e; : ct = ct + 1 IF ct MOD 5 = 0 THEN PRINT : ELSE PRINT "|"; END IF NEXT: NEXT: NEXT: NEXT: NEXT 'print result PRINT PRINT "Total of "; ct; " four of a kind." FUNCTION CountEq (a, b, c, d, e) '*** count how many of five numbers are the same DIM x(5) x(1) = a x(2) = b x(3) = c x(4) = d x(5) = e max = 0 FOR j = 1 TO 5 ck = 0 FOR k = 1 TO 5 IF x(j) = x(k) THEN ck = ck + 1 NEXT k ck = -ck IF ck > max THEN max = ck NEXT j 'assign value to function CountEq = max '\end{verbatim}%\ep END FUNCTION