Skip to main content
added 83 characters in body
Source Link
user11485
user11485

#Ruby

The question asks for a SEQUENCE. Here we go again...

class A;$seed end#random= seed$$.to_i
def getRandom(seed)
        a = AClass.new
        b = a.new
        $seed = a.object_id.to_i#maketo_i it+ aseed decimal- integer$seed
        $seed
end

def getRandomSequence(num)
        molly = Array.new
        0.upto(num) do |x| molly[x] = x*getRandom(x) - getRandom(0-x) end
        molly
end

This is 100% random. No really.
Too bad this code means NOTHING to the OP (what the hell is object_id?)
Also, it's implementation specific, meaning it works or doesn't between different ruby versions (ran this on 2.1.0p0).
On top of that, this can potentially do something really nasty, since OP might experiment with object_id...

Example output:

getRandomSequence(5)
=>
-128872309402224
2012887226055
1288723090025774454222
2577446170038661682243
3866169242051548910124
5154892306064436137991

#Edit: modified to use $$ for true randomness (on the OS level).

#Ruby

The question asks for a SEQUENCE. Here we go again...

class A; end#random seed
def getRandom()
        a = A.new
        a.object_id.to_i#make it a decimal integer
end

def getRandomSequence(num)
        molly = Array.new
        0.upto(num) do |x| molly[x] = x*getRandom - getRandom end
        molly
end

This is 100% random. No really.
Too bad this code means NOTHING to the OP (what the hell is object_id?)
Also, it's implementation specific, meaning it works or doesn't between different ruby versions (ran this on 2.1.0p0).
On top of that, this can potentially do something really nasty, since OP might experiment with object_id...

Example output:

getRandomSequence(5)
=>
-12887230940
20
12887230900
25774461700
38661692420
51548923060

#Ruby

The question asks for a SEQUENCE. Here we go again...

$seed = $$.to_i
def getRandom(seed)
        a = Class.new
        b = a.new
        $seed = a.object_id.to_i + seed - $seed
        $seed
end

def getRandomSequence(num)
        molly = Array.new
        0.upto(num) do |x| molly[x] = x*getRandom(x) - getRandom(0-x) end
        molly
end

This is 100% random. No really.
Too bad this code means NOTHING to the OP (what the hell is object_id?)
Also, it's implementation specific, meaning it works or doesn't between different ruby versions (ran this on 2.1.0p0).
On top of that, this can potentially do something really nasty, since OP might experiment with object_id...

Example output:

-2224
12887226055
25774454222
38661682243
51548910124
64436137991

#Edit: modified to use $$ for true randomness (on the OS level).

Source Link
user11485
user11485

#Ruby

The question asks for a SEQUENCE. Here we go again...

class A; end#random seed
def getRandom()
        a = A.new
        a.object_id.to_i#make it a decimal integer
end

def getRandomSequence(num)
        molly = Array.new
        0.upto(num) do |x| molly[x] = x*getRandom - getRandom end
        molly
end

This is 100% random. No really.
Too bad this code means NOTHING to the OP (what the hell is object_id?)
Also, it's implementation specific, meaning it works or doesn't between different ruby versions (ran this on 2.1.0p0).
On top of that, this can potentially do something really nasty, since OP might experiment with object_id...

Example output:

getRandomSequence(5)
=>
-12887230940
20
12887230900
25774461700
38661692420
51548923060