samedi 28 mars 2015

Building an array from bottom up

Ok so I am trying to build an array in python from the last row first column, build the last row, and then go up to the second to last row first column and son on.


In other words:


First iteration store data to (n=m=1000 valuex is of 'store_data'):



- - - - -
- - - - -
- - - - -
- - - - -
x - - - -


next iteration store data to (n=1100, m = 1000 x is value of 'store_data'):



- - - - -
- - - - -
- - - - -
- - - - -
- x - - -


6th iteration store data to (n=1000, m = 1100 x is value of 'store_data'):



- - - - -
- - - - -
- - - - -
x - - - -
- - - - -


and so on up until (n=2000, m = 2000 x is value of 'store_data')



- - - - x
- - - - -
- - - - -
- - - - -
- - - - -


Conditions on where to store



n,m = 1000
while(1):
if m<2000 and n<2000
n=n+100
if m<2000 and n>=2000
m = m + 100
n=1000
if m>=2000 && n>=2000
m = 1000
n= 1000


So if the first condition is met then I want the value of say the variable 'store_data' in the spot of the first iteration. The if statements are in a while forever loop and store_data gets a new value from a sensor on each iteration of the while loop. So in other words: the array will be 10 x 10 and the last row first column will be the value of 'store_data' when m, n =1000, while the first row last column will be the value of 'store data' when m, n = 2000.


Gosh, I am having a hard time articulating this. But I think it is clear for what I want. What code do I have to add to build this array to my if statements?


Aucun commentaire:

Enregistrer un commentaire