473,473 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Number of Possible Combinations!!-Help!

6 New Member
Hiya,

I am a newcomer to programming and really stuck!!! Any help would be gratefully received!!

I have written a program that gives me all possible combinations for 1 and 2 for a length of 60 digits but is taking for ever to run.

My problems are that the number of 1’s and 2’s must be equal, thirty 1’s and thirty 2’s in every possible combination.

For instance
11111111111111111111111111111122222222222222222222 2222222222
or
12121212121212121212121212121212121212121212121212 1212121212
And so on


Thank you

Suzie
Dec 7 '06 #1
4 2245
Suzie1986
6 New Member
Hiya,

I am a newcomer to programming and really stuck!!! Any help would be gratefully received!!

I have written a program that gives me all possible combinations for 1 and 2 for a length of 60 digits but is taking for ever to run.

My problems are that the number of 1’s and 2’s must be equal, thirty 1’s and thirty 2’s in every possible combination.

For instance
11111111111111111111111111111122222222222222222222 2222222222
or
12121212121212121212121212121212121212121212121212 1212121212
And so on


Thank you

Suzie

can any body help me at all do you need to see the code i have first??
Dec 8 '06 #2
Suzie1986
6 New Member
here the code i have already but does not give me balance of 1's and 2's

Dim flag As Boolean
Public Sub Engine(char As String, length As Byte)

ReDim ary(length)
Dim depth As Byte
Dim result As String

depth = 1

While Not (flag)
k = DoEvents()
ary(depth) = ary(depth) + 1

If depth = length Then
result = Left(result, length - 1) + Mid(char, ary(depth), 1)
Else
result = result + Mid(char, ary(depth), 1)
End If

If ary(depth) <> Len(char) + 1 Then
If depth <> length Then
depth = depth + 1
Else
lblresult.Caption = result
If chcsave.Value = 1 Then
Print #1, result
End If
End If
Else
If depth = 1 Then
flag = True
Else
ary(depth) = 0
depth = depth - 1
result = Left(result, depth - 1)
End If
End If
Wend


End Sub

Private Sub cmdcalc_Click()
If cmdcalc.Caption = "Start" Then
flag = False
txtchar.Enabled = False: txtlength.Enabled = False
cmdcalc.Caption = "Stop"
chcsave.Enabled = False
If chcsave.Value = 1 Then
MsgBox "Save in result.txt"
Open App.Path + "\results.txt" For Output As #1
End If
Call Engine(txtchar.Text, txtlength.Text)
cmdcalc.Caption = "Start"
If chcsave.Value = 1 Then
Close #1
End If
txtchar.Enabled = True: txtlength.Enabled = True
chcsave.Enabled = True
Else
flag = True
chcsave.Enabled = True
txtchar.Enabled = True: txtlength.Enabled = True
cmdcalc.Caption = "Start"
End If
End Sub

Private Sub txtchar_Change()
Call check
End Sub

Private Sub txtlength_Change()
Call check
End Sub

Public Sub check()
If txtchar.Text <> "" Then
If IsNumeric(txtlength.Text) And Val(txtlength.Text) > 0 Then
cmdcalc.Enabled = True
Else
cmdcalc.Enabled = False
End If
Else
cmdcalc.Enabled = False
End If
End Sub
Dec 8 '06 #3
aaryan
82 New Member
hi,
i am working on it. well until then i would also suggest you to work with small digits, say a combination of 1 and 2 for 4 digits. say 1212,1122,1221,2211,2121
and 2112, etc.
Dec 8 '06 #4
Suzie1986
6 New Member
thank you very much the main problem i have is the balance of 1's and 2's must be equal
Dec 8 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

36
by: Dag | last post by:
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N,...
11
by: lostinpython | last post by:
I'm having trouble writing a program that figures out a prime number. Does anyone have an idea on how to write it? All I know is that n > 2 is prim if no number between 2 and sqrt of n...
27
by: Mike P | last post by:
I will be passing my function a two dimensional array of varying length. Within that array is one data point, and the number of times it should loop through. So, for example, I might pass this...
6
by: Eduardo78 | last post by:
If someone could help me doing a code in VB to do the following: The output should be a list of all posible ways in which (m) different Males and (f) different female could be line up if no two...
19
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
22
by: MLH | last post by:
If 3 things can be in one of 2 states, the number of possible combinations is equal to 2^3. But if I have 3 things, 2 of which can be in 2 states and the other in 3 states, what's the simplest...
28
by: beach.dk | last post by:
Hi, I'm trying to implement a simple hash algorith called rs_hash in javascript, but I cannot get a correct result. In c the code looks like this:
2
by: Paul Furman | last post by:
I don't know, maybe this isn't strange but someone else set up the shopping card coding I'm working with, the way it works is to get the time() in seconds like 1172693735 and that's the shopper_ID...
5
by: Bails | last post by:
Hi all I have a theory for a lotto system and need help on how to code it. I want to create 1 massive database with EVERY combination of numbers possible in a given lotto system, then remove all...
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.