# two column number values generator

Go to solution Solved by Danyfirex,

## Recommended Posts

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 on other sites

• Solution

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)```

AutoIt...

##### Share on other sites

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

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...