| View previous topic :: View next topic |
| Author |
Message |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue May 27, 2003 10:36 pm Post subject: Combinations... |
|
|
I'm absolutely stumped on how to make every possible combination of
a string of numbers starting at 0 and ending at 255.
I'm trying to make a script which will make every combination of numbers
starting from 0|0|0 to 255|255|255. I have spent many hours thinking
about this and I just don't know how it is done.
In other words, I need help on making a script that makes every
combination, such as 245|32|80 etc., all the way to 255|255|255.
Thanks in advance for any help!  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue May 27, 2003 11:24 pm Post subject: |
|
|
Parse the string since it has "|" in it. Use IF @GREATER() to insure that
each is not greater than 255, if so, then take the number back down to
255.
Then for low end, IF @EQUAL(@SUBSTR(%%VAR,1,1),-), if so, then take
the number back up to 0.
Once done, put all 3 variables back into a string again.
-Garrett |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue May 27, 2003 11:29 pm Post subject: |
|
|
I'm not sure I follow you entirely.
Could you please explain further?
I really appreciate your help.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed May 28, 2003 12:46 am Post subject: |
|
|
| Code: | %%FullVar = -0|256|23
INFO %%FullVar
Option Fieldsep,|
Parse "%%Var1;%%Var2;%%Var3",%%FullVar
If @greater(%%Var1,255)
%%Var1 = 255
ElsIf @equal(@substr(%%Var1,1,1),-)
%%Var1 = 0
End
If @greater(%%Var2,255)
%%Var2 = 255
ElsIf @equal(@substr(%%Var2,1,1),-)
%%Var2 = 0
End
If @greater(%%Var3,255)
%%Var3 = 255
ElsIf @equal(@substr(%%Var3,1,1),-)
%%Var3 = 0
End
%%FullVar = %%Var1|%%Var2|%%Var3
INFO %%FullVar |
-Garrett |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed May 28, 2003 12:47 am Post subject: |
|
|
The basic premis would be as follows
| Code: |
List create,1
%A = 0
%B = 0
%C = 0
%D = 0
list add,1,%A|%B|%C
repeat
If @equal(%D,1)
%A = @succ(%A)
end
list add,1,%A|%B|%C
repeat
If @equal(%D,1)
%B = @succ(%B)
end
list add,1,%A|%B|%C
repeat
If @equal(%D,1)
%C = @succ(%C)
end
%D = 1
list add,1,%A|%B|%C
until @equal(%C,255)
%C = 0
until @equal(%B,255)
%B = 0
until @equal(%A,255)
list savefile,c:\count.txt
shell open,c:\count.txt
end
|
%D is to make sure that "0" is used before @succ()
The problem here is that your list will run out of memory when %A gets to "3" or "4"
Maybe if you somehow played with it to get more than one set per line.
I think I read in a earlier post that a list has a maximum number of characters
Hope this helps get you started. |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed May 28, 2003 1:20 am Post subject: |
|
|
Here is a visual example
| Code: |
DIALOG CREATE,Test,-1,0,40,27
DIALOG ADD,text,TX,6,24,,,
DIALOG SHOW
%A = 0
%B = 0
%C = 0
%D = 0
dialog set,tx,%A|%B|%C
repeat
If @equal(%D,1)
%A = @succ(%A)
end
dialog set,tx,%A|%B|%C
repeat
If @equal(%D,1)
%B = @succ(%B)
end
dialog set,tx,%A|%B|%C
repeat
If @equal(%D,1)
%C = @succ(%C)
end
%D = 1
dialog set,tx,%A|%B|%C
rem ** remove the "REM" below to see it slower **
rem wait .001
%E = @event()
If %E
goto %E
end
until @equal(%C,255)
%C = 0
until @equal(%B,255)
%B = 0
until @equal(%A,255)
:close
end
|
|
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed May 28, 2003 2:12 am Post subject: |
|
|
Looks like I misunderstood what he wanted.. I think you have what
he's looking for.
-Garrett |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed May 28, 2003 6:07 am Post subject: |
|
|
Hey FF
Why on Earth do you wanna make such a list?? You need a list of every darn IP address, or what
Or are ya just trying to pass time in this snoozefest by figuring out how to do it?
Before you do that for real, try to do some simple math of combinations - we're talkin' several billion combinations -
I doubt it that you really wanna try to manage such a GB list in VDS
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Hortalonus Valued Contributor


Joined: 15 Mar 2002 Posts: 344 Location: Western USA
|
Posted: Wed May 28, 2003 1:21 pm Post subject: |
|
|
| Dr. Dread wrote: | | just trying to pass time in this snoozefest... |
That is the funniest thing I've heard in a long time! Here we are just trying to pass time in this snoozefest... waiting for VDS 5.  _________________ "ah, come take my hand... we're ridin' out tonight to face the promised land"
Get a free iPod mp3 player... |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed May 28, 2003 7:05 pm Post subject: |
|
|
| Dr. Dread wrote: | Hey FF
Why on Earth do you wanna make such a list?? You need a list of every darn IP address, or what
Or are ya just trying to pass time in this snoozefest by figuring out how to do it? |
Well I just wanted to make a cool screensaver.
I wanted it to blend from color to color but I don't know how to do that.
Anyway I wouldn't store a whole list like that, I would just go to the next
color shade/value.
BTW, it's the VDS way of stating an RGB color value.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed May 28, 2003 7:11 pm Post subject: |
|
|
BTW, Thanks a million everybody who helped.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed May 28, 2003 7:21 pm Post subject: |
|
|
| FreezingFire wrote: |
Well I just wanted to make a cool screensaver.
I wanted it to blend from color to color but I don't know how to do that.
Anyway I wouldn't store a whole list like that, I would just go to the next
color shade/value.
BTW, it's the VDS way of stating an RGB color value.  |
Ahaaaa. So it was RGB values he-he, in my mind it was IP addresses - that what ya get for posting
sooo early in the morning
Can't believe I missed the RGB connection - I'm currently trying to figure out how to calculate complementary colors
and split complementary colors for a given color.
Anyways good luck with you colorful screensaver
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri May 30, 2003 1:35 pm Post subject: |
|
|
| Dr. Dread wrote: | Hey FF
Why on Earth do you wanna make such a list?? You need a list of every darn IP addressGreetz
Dread |
BTW Dr. Dread IP addresses have 4 octets in them not 3 like RGB
192.168.000.001 = IP address
128|128|128 = RGB colors
Anyway WAKE UP!  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Fri May 30, 2003 1:46 pm Post subject: |
|
|
| mindpower wrote: |
BTW Dr. Dread IP addresses have 4 octets in them not 3 like RGB
192.168.000.001 = IP address
128|128|128 = RGB colors
|
Yeah, I know. That's why I said the possible combinations would go into billions - with just three it'll only
be about 16 million.
And that's why that post was sooooo off on a tangent
| mindpower wrote: | Anyway WAKE UP!  |
Yup, just slapped myself - now I'm wide awake and ready for action...
Not much action around, though - still a snoozefest around here.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Jul 16, 2003 11:12 pm Post subject: |
|
|
How can I extend the example above to work with four numbers like:
#|#|#|#
I appreciate any help.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|