Recent Posts
mIRC | 7 sec ago
None | 10 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Java | 1 min ago
Java | 2 min ago
Java | 2 min ago
None | 2 min ago
None | 3 min ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 9th of Feb 2010 11:41:52 PM
Download |
Raw |
Embed |
Report
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace PuzzleKornShell
{
public partial class Form1 : Form
{
//String abc = "qwertyuiopasdfghjklzxcvbnm";
String abc = "abcdefghijklmnopqrstuvwxyz";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public string rAlph()
{
String alph = "";
while (alph.Length < abc.Length)
{
int x = r.Next(0, abc.Length);
while (alph.Contains(Convert.ToString(abc[x]))) x = r.Next(0, abc.Length);
alph += abc[x];
}
return alph;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
int max = 0;
String ut = "";
listBox1.Items.Clear();
for (int k = 0; k < 1000; k++)
{
String s = "";
String alph = rAlph();
String x = textBox1.Text;
int kos = 1;
while (kos < 1000000)
{
for (int i = 0; i < x.Length; i++)
{
int c = x[i] - 97;
if (c >= 0 && c < 28)
{
s += alph[c];
}
else
{
s += x[i];
}
}
x = s;
if (textBox1.Text.Equals(s)) break;
s = "";
kos++;
}
if (kos > max)
{
max = kos;
ut = alph;
}
//listBox1.Items.Add(alph + ": " + Convert.ToString(kos));
}
listBox1.Items.Add("MAX: " + ut + ": " + Convert.ToString(max));
button1.Enabled = true;
skriv(ut);
}
private void skriv(String EkkeltAlfabet)
{
String s = "";
String alph = EkkeltAlfabet;
String x = textBox1.Text;
int kos = 1;
while (kos < 1000000)
{
for (int i = 0; i < x.Length; i++)
{
int c = x[i] - 97;
if (c >= 0 && c < 28)
{
listBox1.Items.Add("** Replaced " + x[i] + " with " + alph[c]);
s += alph[c];
}
else
{
s += x[i];
}
}
x = s;
listBox1.Items.Add(Convert.ToString(kos) + ": " + x);
if (textBox1.Text.Equals(s)) break;
s = "";
kos++;
}
}
}
}
Submit a correction or amendment below.
Make A New Post