lundi 24 août 2015

C-Sharp and Linq: Elegant Way To select x from (n *p) items [on hold]

Is there an elegant way (using Linq) to take the following inputs:

  • n = 30 (randomly generated, 0>=n<=100))
  • p = 0.94247 (randomly generated, 0<=p<=1)
  • x = 7 (randomly generated, 1<=x<=23) to generate (n * p) pairs of numbers and (n - (n * p)) single numbers in an array: [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,16] from which to pick x randomly sorted in order: [2,2,5,9,10,12,12]. If x < (n * p), then randomly select and order (n * p) items.

Please advise?

matekus.




Aucun commentaire:

Enregistrer un commentaire