#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_INT 2147483647
typedef enum { false, true } bool;
int rndChar()
{
return 97 + (rand() % 26);
}
int main()
{
bool found = false;
char *key = "erel";
size_t len = strlen(key);
unsigned int i, s;
for (s = 0; s < MAX_INT; ++s) {
srand(s);
for (i = 0; i < len; ++i) {
found = false;
if (rndChar() != key[i]) { break; }
found = true;
}
if (found) return s;
}
return -1;
}
How did you find it?
Dim seed As Long = -1
Dim s As String
Do Until s = "ilan"
s = ""
seed = seed + 1
RndSeed(seed)
For i = 1 To 4
s = s & Chr(Rnd(48, 123))
Next
Loop
Log(seed)
Dim found As Boolean
Dim guess As Char
Dim key = "Erel" As String
Dim seed = -1 As Long
Do Until found
found = True
seed = seed + 1
RndSeed(seed)
For i = 0 To (key.Length - 1)
If Chr(Rnd(48, 123)) <> key.CharAt(i) Then
found = False
Exit
End If
Next
Loop
Log(seed)
If Chr(Rnd(48, 123)) <> key.CharAt(i) Then
found = False
Exit
End If
Strange enough, your seed is a prime number. Perhaps you should ask for a free lifetime suscriptionmy seed is: 56205181
Dim t As Long 'Timestamp / completion time
Dim s = -1 As Long 'Seed
Dim i = 0 As Int 'Iterator
Dim k = "Erel" As String 'Key
Dim l = k.Length As Int 'Key length
Dim c(l) As Int 'Numeric key (array)
For p = 0 To l - 1
c(p) = Asc(k.CharAt(p))
Next
t = DateTime.now 'Start benchmark
'===============================================
Do While i < l
i = 0
s = s + 1
RndSeed(s)
Do While i < l And Rnd(48, 123) = c(i)
i = i + 1
Loop
Loop
'===============================================
t = DateTime.Now - t 'End benchmark
Log("Key : " & k)
Log("Seed : " & s)
Log("Time : " & (t * 0.001) & " sec")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef enum { false, true} bool;
// Returns a random lower-case character
int rndChar()
{
return 97 + (rand() % 26);
}
int main()
{
char *k = "erel";
size_t l = strlen(k);
size_t i = 0;
int s = -1;
while (i < l && !(i = 0)) {
srand(++s);
while (i < l && rndChar() == k[i] && ++i);
}
return s;
}