Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/frog/ challenge sqrt(-2): unique (pseudo)random snowflake numbers

Name: Anonymous 2019-01-22 12:49

your're are task: implement a random number generator which works according to the following specification:
  • takes two command-line arguments; first will be the seed, second will be how many numbers to generate
  • outputs numbers separated by newline to stdout
  • if called \(2^{32}\) times, it will output each \(x\) defined as \(0 <= x < 2^{32}\) exactly once
  • order of such outputs will not be trivially predictable, but it doesn't have to be cryptographically secure: \(0, 1, 2, 3 ... 2^{32}\) is not ok but an LSFR is
  • each seed should generate a different sequence, there should not be a single sequence with seeds working as offsets into it

you have one week. the shortest code (in bytes of source code or compiled executable) wins, but submissions will be scored in two separate categories: those that achieve uniqueness algorithmically and those that guarantee it by explicitly caching the results. the category which does not use caching should be seen as the more prestigious one since caching is a trivial hack and it will ruin performance and/or memory usage for large sequences

Name: Anonymous 2019-01-22 17:17

so just to be clear, you're essentially asking for a program that computes a permutation (bc uniqueness) of the 32-bit integers. Since each seed should generate a different permutation, you'd need a function F : nat -> nat -> nat, such that (F n) is a non-trivial permutation for each n. (and then just call it in sequence to print the first k numbers)

There are only finitely many permutations, so it's impossible to generate a different one for __every__ seed. There should be a requirement that we can assume the seed to have log(2^32-factorial) many bits, so there are at most 2^32-factorial different seeds.

Name: Anonymous 2019-01-22 17:26

>>6
There are only finitely many permutations, so it's impossible to generate a different one for __every__ seed. There should be a requirement that we can assume the seed to have log(2^32-factorial) many bits, so there are at most 2^32-factorial different seeds.
OP here, your're are right, of course. sorry if I wasn't being clear

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List