[Webinar] Streamline your web hosting managementRegister Today

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 240

# Finding the smallest 'combination' of a number

Hi! I need to do some 'puzzle' and I encounter problem when trying to figure out the smallest combination of a number. eg - I got the number 3412 and the number got 24 combination(1234, 1243, 1423, etc, etc). I want my app to find out the smallest value from the possible combination - 1234

Thank you,
0
aboka
• 2
1 Solution

Commented:
Just

for i=1 to numberofdigital

combin = combin * i

next
0

Commented:
First sort the numbers

dim inLen as integer
dim array1() as integer
inLen = Len(stString)
redim array1(1 to inLen)
For inI = 1 to inLen
array1(inI) = mid(ststring,inI,1)
Next inI

For inI = 1 to inLen -1
For inJ = 1 to inLen - inI
if array1(inJ) > array1(inJ + 1) then
inTemp = array1(inJ)
array1(inJ) = array1(inJ + 1)
array1(inJ + 1) = inTemp
end if
NExt inJ
Next inI

'  Now the numbers are sorted smallest to largest

For inI = 1 to inLen
mid(ststring,inI,1) = array1(inI)
Next inI

'  Now they are back in the string from smallest to largest

0

Commented: