Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Random distribution [closed]
  2. static Random random = new Random();
  3. public static void Main(string[] args)
  4. {
  5.     var list = new List<int>(Enumerable.Range(1,200));
  6.     while(list.Count>0)
  7.     {
  8.         var item = list[random.Next(0,list.Count)];
  9.         list.Remove(item);
  10.  
  11.         // Do something with 'item'
  12.     }
  13. }
  14.        
  15. var tables = new List<int>[36];
  16. for(var i=0;i<36;i++)
  17. {
  18.     tables[i] = new List<int>();
  19. }
  20.  
  21. var stack = new Queue<int>(Enumerable.Range(1,300));
  22. while(stack.Count>0)
  23. {
  24.     var next = stack.Dequeue();
  25.     var table = tables[random.Next(0,36)];
  26.     table.Add(next);
  27. }