Skip to content

Instantly share code, notes, and snippets.

@millimoose
Last active March 14, 2017 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millimoose/1562aa304180d022c8d6553f872244fc to your computer and use it in GitHub Desktop.
Save millimoose/1562aa304180d022c8d6553f872244fc to your computer and use it in GitHub Desktop.
void Main()
{
var d6range = Enumerable.Range(1, 6);
var rolls = from d1a in d6range // first die of first roll
from d1b in d6range // second die of first roll
from d2a in d6range // first die of second roll
from d2b in d6range // second die of second roll
select new { d1a, d1b, d2a, d2b }; // all four dice rolled
var advantages = from r in rolls
let r1 = r.d1a + r.d2a // total of first roll
let r2 = r.d2a + r.d2b // total of second roll
select Math.Abs(r1-r2); // the advantage
advantages.Average().Dump();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment