ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on nested loops (https://www.excelbanter.com/excel-programming/305399-help-nested-loops.html)

Jan Lukszo

Help on nested loops
 
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




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

Help on nested loops
 
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)

"Jan Lukszo" wrote in message
...
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




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 03:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com