Created
November 29, 2015 20:45
-
-
Save loctanvo/d150db1fa98b400eb25e 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; | |
using System.Threading; | |
namespace MathRandom | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var random1 = new Random(Guid.NewGuid().GetHashCode()); | |
var random2 = new Random(Guid.NewGuid().GetHashCode()); | |
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