Staring at loops

hi all,
i have this head breaker puzzle that i can use help in solving. I have been staring at it and trying a few hours now and my vision has become blurred.
It has to do with a loop in a loop.

i’m afraid to show one of my test codes here, because i know this is (very) bad…
Perhaps for someone this is a piece of cake?

What is my goal: create an i-rate loop.

  • have ixstart loop and print it (ixstart += 1) until it has reached 5- i know this one
  • then move on and add 2 to it. That makes it 7- doable as well
  • go back and do this 3 times (or more)- now things start to blur…

the result should be: 1,2,3,4,5, 7,8,9,10,11, 13,14,15,16,17, …etc

(Under pressure i am willing to show my bad code)

hi menno -
something like this? best -

instr 1
iStart = 1
iNumLoops = 5
iThisLoop = 0
iArr[] init 5
while (iThisLoop < iNumLoops) do
indx = 0
while (indx < 5) do
iArr[indx] = iStart+indx
indx += 1
iThisLoop += 1
iStart += 6

hmm indendation is ruined in the email — so here once again attached.

test2.csd (713 Bytes)

Great code, but not what i was looking for :blush:
although i can see the beauty of using arrays, it also obliges me to study how arrays work before continuing the project i am working on. Maybe this is the time for this study, because one thing leads to another…not sure yet.

I was hoping / looking for something more old skool, so code based on adding and loops without arrays.

So output should be, if 5 values are to be printed, the 6th skipped, then go on counting another 5 starting at 7, skip one value after 11 , etc etc until i say: stop at 100 for example
1,2,3,4,5, 7,8,9,10,11, 13,14,15,16,17, 19,20,21,22,23, 25…100

I think this would take yet another loop construction to replace the counting of the array.
I will start by creating one loop and looping that loop. If i still understand what is happening, i will add yet another loop.

Thanks, Joachim, for your code.
I fear the come has come to start the array study :grinning: I am sure it will pay off in the long run

yeah if it is only about printing, the solution without arrays is
perhaps simpler.
we can count from 1 to 100 and after 5 values stop printing for one number.
not sure i missed something, but you can compare the code attached.

test2.csd (1.28 KB)

wow, you really control this. Nice to see.

This is definitely better readable for me. And a soft introduction to the array world. Thanks!
Something to build upon.

your question was interesting for me, too.
meanwhile i realized that there is a much simpler version with arrays:

instr 1
iNumbers[] = fillarray(1,2,3,4,5)
while (iNumbers[0] < 100) do
iNumbers += 6

perhaps even more motivation for you to approach this field. and cs7
will probably offer some new facilities.


this is close to art, Joachim.
The aesthetics of it is yet another motivation!