[Webinar] Streamline your web hosting managementRegister Today

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

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

Please advice with sample coding if possible.


Thank you,
0
aboka
Asked:
aboka
  • 2
1 Solution
 
EDDYKTCommented:
Just

in your case numberofdigital=4



for i=1 to numberofdigital

combin = combin * i

next
0
 
JacamarCommented:
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
 
EDDYKTCommented:
Ignore will answer i misread the question
0
 
abokaAuthor Commented:
You are the BEST! Thank you very much,

cheers,
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now