Last active
November 29, 2015 20:45
-
-
Save loctanvo/cdb63f7f73a3fd873564 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
using System; | |
using System.Linq; | |
namespace MathRandom | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var random1 = new Random(); | |
var random2 = new Random(); | |
Console.WriteLine("|------------|------------|------------|"); | |
Console.WriteLine("|Random Seq 1|Random Seq 2| Difference |"); | |
Console.WriteLine("|------------|------------|------------|"); | |
Repeat(20, () => | |
{ | |
var seq1 = random1.Next(); | |
var seq2 = random2.Next(); | |
Console.WriteLine("| {0:0000000000} | {1:0000000000} | {2:0000000000} |", seq1, seq2, Math.Abs(seq1-seq2)); | |
}); | |
Console.WriteLine("|------------|------------|------------|"); | |
Console.ReadKey(); | |
} | |
private static void Repeat(int times, Action action) | |
{ | |
Enumerable | |
.Range(0, times) | |
.Select(_ => | |
{ | |
action(); | |
return _; | |
}) | |
.ToList(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment