Public Function GoFigure( _ ByVal vOne As Byte _ , ByVal vTwo As Byte _ , ByVal vThree As Byte _ , ByVal vFour As Byte _ , ByVal vResult As Long _ , Optional ByVal vMaxTries As Variant _ ) As String
Rnd(-1) = 0.224007 GoFigure(2, 7, 7, 7, 9) = "7+2+7-7" GoFigure(2, 2, 6, 7, 6) = "7+2-6*2" GoFigure(2, 5, 6, 6, 360) = "5*6*6*2" GoFigure(5, 5, 8, 9, 315) = "5*8-5*9" GoFigure(2, 4, 7, 8, 3) = "4+8-2-7" GoFigure(1, 1, 5, 5, 26) = "5*5*1+1"Note: The call to the Visual Basic Rnd function in the above example seeds the Visual Basic random number generator so that the sample results can be reproduced. There is generally no need to call the Rnd function within your programs since Entisoft Tools initializes the Visual Basic random number generator once with "Randomize" statement.
RandomLongGenerator FunctionvOne, vTwo, vThree, vFour: Four numbers which, when combined using some combination of +, -, *, and /, result in vResult.
BIG Note: This function currently only returns expressions whose evaluation with left-to-right precedence yields vResult. This function cannot currently solve GoFigure puzzles which use the algebraic precedence for evaluating expressions. With algebraic precedence, multiplication and division is performed first (left-to-right), and addition and subtraction is performed next (again, left-to-right).
Note: This function has restrictive argument types to avoid argument fix-up overhead, therefore it does not support multi-valued logic.
Algorithm: This function is NP-Random, and not particularly well optimized, so it might take it several seconds to find a valid solution. Also, it may never find a solution within the specified maximum number of tries, or if its arguments are inconsistent and thus have no solution.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.