-
Notifications
You must be signed in to change notification settings - Fork 0
/
MonkyTyping.cs
43 lines (37 loc) · 1.3 KB
/
MonkyTyping.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MonkyTyping
{
class Program
{
public static readonly char[] all_chars = new char[] {'a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k','l','m','n', 'o','p', 'q', 'r','s', 't', 'u', 'v', 'w', 'x' , 'y', 'z'};
public static readonly String match = "match";
static void Main(string[] args)
{
DateTime startTime = DateTime.Now;
int count = Typing();
Console.WriteLine("GOT MATCHED! When " + count.ToString() + " words generated." );
DateTime stopTime = DateTime.Now;
Console.WriteLine(stopTime - startTime);
Console.ReadLine();
}
private static int Typing()
{
Random rd = new Random();
for (int i = 0; true ; i++)
{
System.Text.StringBuilder word = new System.Text.StringBuilder(match.Length);
for (int j = 0; j < match.Length; j++)
{
word.Append(all_chars[rd.Next(all_chars.Length)]);
}
//Console.WriteLine(word.ToString());
if (match == word.ToString())
return i;
}
}
}
}