lundi 25 février 2019

JavaScript | Genetate a table with conditions

Hello everyone

I need to generate a table like this :

enter image description here

but with lot of condition :

1 index[0] must be between 0 & 9

2 index[n] depends on the sum of prev indexs

 let's define a variable sum of all prev indexs

IF ( sum == 0 ) => index [n+1] can be a number between 0 & 9

IF ( sum == 1 ) => index[n+1] can be one of this array [-1,0,1,2,3,5,6,7,8]

IF ( sum == 2 ) => index[n+1] can be one of this array [-2,-1,0,1,2,3,5,6,7]

IF ( sum == 3 ) => index[n+1] can be one of this array [-3,-2,-1,0,1,2,3,5,6]

IF ( sum == 4 ) => index[n+1] can be one of this array [-4,-3,-2,-1,0,1,2,3,5]

IF ( sum == 5 ) => index[n+1] can be one of this array [-5,0,1,2,3,4]

IF ( sum == 6 ) => index[n+1] can be one of this array [-6,-5,-1,0,1,2,3]

IF ( sum == 7 ) => index[n+1] can be one of this array [-7,-6,-1,-2,0,1,2]

IF ( sum == 8 ) => index[n+1] can be one of this array [-8,-7,-6,-5,-3,-2,-1,0,1]

IF ( sum == 9 ) => index[n+1] can be one of this array [-9,-8,-7,-6,-5,-4,-3,-2,-1,0]

i need a script that allow me to generate tables




Aucun commentaire:

Enregistrer un commentaire