Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (ozgur, Quad), 880 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Create random word list #173960
12/20/07 10:23
12/20/07 10:23
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline OP
Expert
FeiHongJr  Offline OP
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Just curious if anyone has any thoughts on how to implement this idea.

Basically I want to create a random 'word' list using characters,numbers and possibly symbols and have that info printed out to a .txt file as it generates.

For example:

Using the A a B b 1 2 as an example

I would like the code to generate all possible combinations so...

A
Aa
AA
AB
Ab
A1
A2
a
aA
aa
aB
ab
a1
a2
B
BA
Bb
etc...

Then write them to a .txt file in that format as they are generated. Does anyone have any ideas?


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: Create random word list [Re: FeiHongJr] #173961
12/20/07 11:08
12/20/07 11:08
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
Maybe fill an array with the characters. The array only would hold a pointer to a string, though. Then loop through the array and loop inside the loop again to add a second letter. Something like:

Code:

var ArrayOfChars[6];

..

function SetupChars()
{
ArrayOfChars[0] = str_create("A");
ArrayOfChars[1] = str_create("a");
ArrayOfChars[2] = str_create("B");
ArrayOfChars[3] = str_create("b");
ArrayOfChars[4] = str_create("1");
ArrayOfChars[5] = str_create("2");
}

var i;
var k;

string first;
string second;
string final;


function CreateWords()
{
while(i != 6)
{
while(k != 6)
{
first = ptr_for_handle(ArrayOfChar[I]);
second = ptr_for_handle(ArrayOfChar[K]);
str_cat(first, second);
//so something with final word combination
final = first;
k += 1;
}
i += 1;
}
}




This is not tested (may not work), and straight of the top of my head. It is probably not a very good method, either. If you were using a long list of different characters it might be better to work with ASCII numbers and convert them back into strings rather than use strings straight off..

Hope it helps,
Adoado


Visit our development blog: http://yellloh.com
Re: Create random word list [Re: adoado] #173962
12/20/07 12:34
12/20/07 12:34
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline OP
Expert
FeiHongJr  Offline OP
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Thanks, Ill have to look at it when im not so tired.

I have a script that does basically this but is javascript and cant figure out how to convert it over. Heres the code...

Code:
 

var current = "";
var set = new Array('a', 'B', '3', '-');

function init()
{
for (var i = 1; i <= set.length; ++i)
go(0, i);
}

function go(pos, maximum)
{
if (pos == maximum)
{
document.write(' current );
return;
}

for (var i = 0; i < set.length; ++i) {
var tmp = current;
current += set[i];
go(pos + 1, maximum);
current = tmp;
}
}



The above code generates a list like so

a
B
3
-
aa
aB
a3

and so on but is for javascript.
Again thanks for all and any help.


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1