Skip to content

miscelleanous-projs/seloto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Seloto

Mba ho fahatsiarovana ny Seloto 6/36 fahiny (taona 1989)

Ohatra:

 2  8 15 24 29 32
 4 10 14 19 24 36
 4 13 16 26 28 36
 9 10 11 21 24 25
 7 17 18 22 32 36
 1  4  9 26 29 33
 2  8 10 23 32 35
10 13 16 17 26 31
 1  2  3  8 17 24
 5 14 16 23 24 35

Source code

Indro ary izay masaka kely nosoratana amin'ny D...

import std.stdio: writefln;
import std.random: MinstdRand0, randomShuffle, unpredictableSeed;
import std.range: array, iota, take;
import std.algorithm.sorting: sort;

auto draw(uint n, uint m)
{
    // Park and Miller's "minimal standard" seed with a constant
    auto rndGenerator = MinstdRand0(1);
    
    // Seed with an unpredictable value
    rndGenerator.seed(unpredictableSeed);
    
    auto res = iota(1, m+1)
                .array
                .randomShuffle(rndGenerator)
                .take(n)
                .sort!"a < b";
    
    version (X86_64)
    
    return res;
}

void main()
{    
    // In remembrance of Seloto 6/36 - The first state run Malagasy lotto back in 1989
    const N = 6;
    const M = 36;
    
    // Print 10
    foreach(i; iota(10))
    {
        auto arr = draw(N, M);
        
        writefln("%(%2s %|%)", arr);
    }
}

Languages