static Random rand = new Random(Guid.NewGuid().GetHashCode());
static int max = int.MaxValue;
public static void Main()
while ((val = (int)Math.Ceiling(val / 2d)) > 1) {
Console.WriteLine("You have {0} attempts", count + 1);
if (Guess(min, max, Verify) == guess)
Console.WriteLine("YEY! Found it!");
public static int Guess(int a, int b, Func<int, Result> CheckNumber) {
Result r = Result.Unknown;
while (Result.Correct != (r = CheckNumber(n)))
n += half = (int)Math.Ceiling(half / 2d);
n -= half = (int)Math.Ceiling(half / 2d);
public static int SecondGuess(int a, int b) {
Result r = Result.Unknown;
while (Result.Correct != (r = Verify(n)))
public static Result Verify(int num) {
guess = rand.Next(min, max);
Result res = Result.Correct;
Console.WriteLine("Your attempt {2} of number {0} is {1}", num, res, attempt);