Last active
March 14, 2017 16:12
-
-
Save millimoose/1562aa304180d022c8d6553f872244fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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