Skip to content

Instantly share code, notes, and snippets.

@theBonesae
Created August 11, 2014 19:43
Show Gist options
  • Save theBonesae/1d9f42a101ae26a5b067 to your computer and use it in GitHub Desktop.
Save theBonesae/1d9f42a101ae26a5b067 to your computer and use it in GitHub Desktop.
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