jeudi 14 mars 2019

Bash obtain multiple number from result

I have these variables

1=10
2=21
3=44
4=36

and need find which variables sum up to 57 In this case is variable 4 + 2.

I think need some random code, maybe some like this.

#!/bin/bash
array[0]=10
array[1]=21
array[2]=44
array[3]=36
Next add random until this fits to result 

But but if I have 100 variables and need to find a result is it possible? I read some links to randomize but I never seen anything like this.




Aucun commentaire:

Enregistrer un commentaire