Generating a specific pattern of numbers

Apologies for this not being like other quite general questions, but here’s the breakdown: I have a list called a, with always will have a length divisible by three. I want a new list called b with length 3 times a, which has the terms a[1 , 2 , 3 , 3 , 2 , 1 , 0 , 0 , 0 , 4 , 5 , 6 , 6 , 5 , 4 , 0 , 0 , 0…] Anyone capable of wrapping their head around this task?

Here I’m using the initial 9 elements to determine later elements in the sequence. There’s certainly a piecewise function that could be made, but I think it would be more complex. There’s both a function and an explicitly defined list dependent on L_istA, depending on your needs.

It works! Unfortunately, you’ve made my head hurt even more. I would much rather have a one script solution, but it seems like the problem requires variables.

Maybe this? I think this is similar to want Daniel provided. Desmos | Graphing Calculator

I’m not sure what you mean by a[1,2,3,3,2,1,0,0,0 …] because a[0] makes no sense …

Here’s my solution to generate the indeces (similar to Daniel’s):
https://www.desmos.com/calculator/nzm5k2gkqi

I think they mean a random index

No, I meant a[0]. The pattern is supposed to make it go forward three, back three, have three undefined terms, then go to the next three terms. I’m trying to make a flag out of one line (very original of me) and the specific pattern is what I need to make it work.

so what we gave should work:
https://www.desmos.com/calculator/nzm5k2gkqi

1 Like

Huzzah it did! I just had to get rid of those pesky variables by substitution. Now I have a good looking one line solution

a\left[\left[1,2,3,3,2,1,0,0,0\right]\left[\operatorname{mod}\left(\left[0…3n-1\right],9\right)+1\right]\ +3\operatorname{floor}\left(\frac{\left[0…3n-1\right]}{9}\right)\operatorname{sign}\left(\left[1,2,3,3,2,1,0,0,0\right]\left[\operatorname{mod}\left(\left[0…3n-1\right],9\right)+1\right]\right)\right]

1 Like