Skip to content

Instantly share code, notes, and snippets.

@bittercoder
Created September 1, 2012 20:42
Show Gist options
  • Save bittercoder/3586713 to your computer and use it in GitHub Desktop.
Save bittercoder/3586713 to your computer and use it in GitHub Desktop.
Monkey Coconuts Brute Force
namespace MonkeyCoconuts
{
class Program
{
static void Main(string[] args)
{
for (int i=0; i<10000000; i++)
{
if (test(i))
{
Console.WriteLine(i);
break;
}
}
Console.ReadLine();
}
static bool test(int number)
{
if ((number - 1) % 5 != 0) return false;
number = number - 1;
number = number - (number/5);
if ((number - 1) % 5 != 0) return false;
number = number - 1;
number = number - (number / 5);
if ((number - 1) % 5 != 0) return false;
number = number - 1;
number = number - (number / 5);
if ((number - 1) % 5 != 0) return false;
number = number - 1;
number = number - (number / 5);
if ((number - 1) % 5 != 0) return false;
number = number - 1;
number = number - (number / 5);
if ((number - 1) % 5 != 0) return false;
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment