Y + n = x in a loop


#1

Hey people,

I am looking for a way to have a list of numbers be added by 1 each time per item in the list. Kinda hard to explain for me, but let me give an example to clear it up:

1 +1 = 2
2 + 2 = 4
6 + 3 = 9
13 + 4 = 17
3 + 5 = 8
55 + 6 = 61
etc.

y + n = x

Where y is a random number from a list and n is a sequential number from 1 to 26 {1…26,1…26,1…26} etc. (letters in the alphabet for my purpose.

Can be done with Python I guess, but I’m not good with that and maybe a code block (which I prefer), but any help is welcome of course.

thanx


#2

@RobinDeurloo if I’m understanding correctly I believe something like this is what you are looking for (ignore the first code block, was just generating a list of numbers to demonstrate):
listplusrange


#3

Yeah that is pretty much what I am looking for BUT I want the added number to be 1 to 26 and again 1 to 26 and that pretty much indefinitely.

So if my list count is 53 the number added to the 27th number of that list should be 1 and the the 28th should be 2 and the 53th should be 1 again.


#4

Ah I understand now :slight_smile: this should work:


#5

Or this


#6

Thanx!
Pretty cool if you can stamp out code just like that :slight_smile:

Gonna use those in my project and see if I can get it to work.


#7

Nope not it I’m afraid.

I think I have explained myself wrong, because when reading my question back you guys answer exactly what I asked.

Let me try again.

The resulting numbers can ONLY be from 1 to 26 (letters in the alphabet). So:

when I have 20 and I ad 20, resulting in 40, the final number should be 40-26=14 (N)
when I have 60 and I ad 10, resulting in 70, the final number should be 70-26-26=18 ( R)
when I have 26 and I ad 1, resulting in 27, the final number should be 27-26=1 (A)

I can use your numbers, do some calculations in Dynamo and end up with a correct list, but I was hoping for a nicer (and shorter) solution.

I hope you are willing to help again :blush:


#8

do yourNumber % 26 in a codeblock.


#9

Sounds like you’re after an alpha-numeric converter. Check the rhythm package as it may save you some headache.


#10

I’m guessing you’re looking for a modulo operation.
@Michael_Kirschner2’s should do for that matter. However, I think mod(26) (that’d be %26 in the code) would go from 0 to 25. You can circumvent that by subtracting 1 before going into that bit and adding 1 afterwards.