Help on nested loops

J

Jan Lukszo

Hi!
I would like to get any helpful suggestion how to approach the following
problem. If I have a single string made of the sequence of capital
letters with no spaces, that may be input by user, and would ordinarily
be n characters long, where n=5 to 100 or even more, different each
time. How to create an Excel spreadsheet or an array, containing all
possible combinations of deletions, where deletion spaces would
gradually increase from 1 to n-1, such that the gradually shortet string
would be created, as schematically outlined below:

ABCDEGTWESRADCRFRIEOPTY
ABCDEGTWESRADCRFRIEOPT
ABCDEGTWESRADCRFRIEOP Y '1 DELETIONS, STARTING FROM RIGHT
ABCDEGTWESRADCRFRIEO TY
ABCDEGTWESRADCRFRIE PTY
ABCDEGTWESRADCRFRI PTY
...................................
..................................
ABCDEGTWESRADCRFRIEO Y
ABCDEGTWESRADCRFRIE P Y '2 DELETIONS, STARTING FROM RIGHT
ABCDEGTWESRADCRFRI OP Y ' FIRST AT POSITION 2, 2ND STARTS AT POS.3 etc
ABCDEGTWESRADCRFR EOP Y
.................................................................
.............................................................
ABCDEGTWESRADCRFRIEOP Y
ABCDEGTWESRADCRFRIE Y ' 3 DELETIONS, STARTING FROM RIGHT
ABCDEGTWESRADCRFRI O Y
..........................................................
.........................................................
A Y ' n-2
DELETIONS, (N-2)TH DELETION AT POSITION 2 FROM LEFT
B Y ' n-2
DELETIONS, (N-2)TH DELETION AT POSITION 1 FROM LEFT

At first I tought of nested loops, but since the lenght of the string
would be different in each case and so would a number of iterations how
to do it? It would probably be n-1 iterations, different each time. Any
alternative to nested loops?

JasL
 
B

Bob Phillips

From your description I have no idea what you are trying to do, but you can
handle variable string lengths by using Len, such as

For i = 1 To Len(myString)
etc.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top