Created
August 11, 2014 19:43
-
-
Save theBonesae/1d9f42a101ae26a5b067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication11 { | |
class Program { | |
static void Main(string[] args) { | |
while (true) { | |
Console.WriteLine("Please enter your strings:"); | |
string[] inputs = Console.ReadLine().Split(','); | |
int iterations = Bogo(inputs[0], inputs[1]); | |
Console.WriteLine(iterations + " iterations"); | |
} | |
} | |
static int Bogo(string arg1, string arg2) { | |
string randomString; | |
int iterations = 0; | |
Random numb = new Random(); | |
do{ | |
randomString = new String(arg1.ToCharArray().OrderBy(s => (numb.Next(2) % 9) == 0).ToArray()); | |
iterations++; | |
}while(!randomString.Equals(arg2)); | |
return iterations; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment