Jump to content

Autoit generate random natural numbers from arrays


Recommended Posts

Hello guys! I got myself locked up trying to solve a problem.How can i generate random natural numbers using ciphers from an array.

For example:

I have this array:

$cipher[10] = [1,2,3,4,5,6,7,8,9,0]

  How could I make the script randomly generate the 5943 number? 

Link to comment
Share on other sites

  • Moderators

@Renderer are you talking something like this?

#include <Array.au3>

Local $cipher[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
    Local $a = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $b = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $c = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $d = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    ConsoleWrite($a & $b & $c & $d & @CRLF)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

1 hour ago, JLogan3o13 said:

@Renderer are you talking something like this?

#include <Array.au3>

Local $cipher[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
    Local $a = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $b = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $c = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    Local $d = Random(_ArrayMin($cipher), _ArrayMax($cipher), 1)
    ConsoleWrite($a & $b & $c & $d & @CRLF)

 

Yeah ! Something like this! Thanks!

Link to comment
Share on other sites

Isn't that the same as:

#include <Array.au3>

; Local $cipher[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]   ; is that a cipher? Really?
Local $a = Random(0, 9, 1)
Local $b = Random(0, 9, 1)
Local $c = Random(0, 9, 1)
Local $d = Random(0, 9, 1)
ConsoleWrite($a & $b & $c & $d & @CRLF)

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...