Sign in to follow this  
Followers 0
face

two column number values generator

3 posts in this topic

#1 ·  Posted (edited)

i have two columns of numbers

i want to make it so column 1 generates from numbers 0-50 and column 2 from column 1's value to 255 max and possibly able to set how many rows (around 1000 rows)

if column 1 generates = 2

column 2 generates = from 2 to 255 randomly

and possibly no repeat/duplicates option

Edited by face

Share this post


Link to post
Share on other sites



almost same code I show before.

#include <Array.au3>

Local $if=100
Local $icol=100
Local $aRamdom[$if][$icol]
Local $aRIndex[4]=[0,50,255,1000]
For $f=0 to $if-1
    For $c=0 to $icol-1
        $aRamdom[$f][$c]=Random($aRIndex[Mod($c,3)],$aRIndex[Mod($c,3)+1],1)
    Next
Next

_ArrayDisplay($aRamdom)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

face,

This will generate a 2 column (2D) array where no rows repeat.  There is also a dup checking and proof routine at the end...

#include <array.au3>

local $irows = 1000
local $aRSLT[$irows][2]
local $CompStr = '', $tRND = 0

for $1 = 0 to ubound($aRSLT) - 1

    $aRSLT[$1][0] = random(0,50,1)
    $tRND = random($aRSLT[$1][0],255,1)

    while stringinstr($CompStr,$aRSLT[$1][0] & '-' & $tRND & '|') > 0
        $tRND = random($aRSLT[$1][0],255,1)
    WEnd

    $CompStr &= $aRSLT[$1][0] & '-' & $tRND & '|'

    $aRSLT[$1][1] = $tRND

next

_arraydisplay($aRSLT)

;
;   Routine to prove array generator does not generate duplicates
;

local $aCHK = stringsplit($CompStr,'|',3), $DupCnt = 0

; to prove dup checking routine...set 499 = 500
; $aCHK[499] = $aCHK[500]

for $1 = 0 to ubound($aCHK) - 1
    $DupCnt = 0
    for $2 = 0 to ubound($aCHK) - 1
        if $aCHK[$1] = $aCHK[$2] then
            $DupCnt += 1
            if $DupCnt > 1 then ConsoleWrite($1 & ' dup = ' & $aCHK[$1] & @CRLF)
        endif
    Next
Next

kylomas

edit: wording

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0