Advertisement
sglienke

Untitled

Aug 25th, 2016
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure RollDice;
  2. var
  3.   data: IEnumerable<IEnumerable<Integer>>;
  4.   results: IEnumerable<IGrouping<string, IEnumerable<Integer>>>;
  5. begin
  6.   data := TEnumerable.Repeated<IEnumerable<Integer>>(TEnumerable.Range(1, 5), 2400000);
  7.  
  8.   results := TEnumerable.GroupBy<IEnumerable<Integer>, string>(data,
  9.     function(const x: IEnumerable<Integer>): string
  10.     begin
  11.       Result := StringJoin('', TEnumerable.Select<Integer,string>(TShuffledEnumerable<Integer>.Create(x), IntToStr));
  12.     end);
  13.  
  14.   Writeln(StringJoin(#13#10, TEnumerable.Select<IGrouping<string, IEnumerable<Integer>>,string>(results,
  15.     function(const group: IGrouping<string,IEnumerable<Integer>>): string
  16.     begin
  17.       Result := group.Key + ': ' + IntToStr(group.Count);
  18.     end)));
  19. end;
Advertisement
RAW Paste Data Copied
Advertisement