Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Random 1-1 mapping

by blokhead (Monsignor)
on May 28, 2006 at 21:26 UTC ( #552217=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    f(x) = (a*x + b) % m
    
  2. or download this
    sub gcd { $_[1] ? gcd($_[1], $_[0] % $_[1]) : $_[0] }
    
    ...
        my @result = map shuffle($seed, 15, $_), 0 .. 14;
        print "seed=$seed ==> @result\n";
    }
    
  3. or download this
    seed=1 ==> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
    seed=2 ==> 0 2 4 6 8 10 12 14 1 3 5 7 9 11 13
    ...
    seed=8 ==> 0 8 1 9 2 10 3 11 4 12 5 13 6 14 7
    seed=9 ==> 1 9 2 10 3 11 4 12 5 13 6 14 7 0 8
    seed=10 ==> 2 10 3 11 4 12 5 13 6 14 7 0 8 1 9
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://552217]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (1)
As of 2023-09-26 10:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?