I am thinking of an idea of a "supercompressor" that could compress random data (or so I wished!).
In a nutshell, it should work like so: take the first to numbers from a binary sequence, find a seed for a sequence generator that would produce these two numbers. Move to the next two numbers. After the first pass, the sequence should be (nearly) twice as short as the original one. Next, repeat this procedure on the sequence of the seeds. And so on until we get to the single seed.
Assume decompression would work in the reverse order - take a seed, produce 2 numbers. Iterate over the two numbers taking each as a seed, produce further numbers.
Omitting many important details, the core of the problem boils down to implementing a GetSeed function for any int values in the code (dotnetfiddle)
private static int GetSeed(int n1, int n2)
{
// how to implement this for any n1 and n2
return 1234567890;
}
public static void Main()
{
int seed = GetSeed (1175335310, 906672726);
var r = new Random(seed);
int n1 = r.Next();
int n2 = r.Next();
Console.WriteLine("Sequence: {" + n1 + ", " + n2 + "}. Seed " + seed);
// Sequence: {1175335310, 906672726}. Seed 1234567890
}
Is it possible to implement GetSeed for two arbitary random integers?
Aucun commentaire:
Enregistrer un commentaire