Skip to content

Instantly share code, notes, and snippets.

@loctanvo
Created November 29, 2015 20:45
Show Gist options
  • Save loctanvo/d150db1fa98b400eb25e to your computer and use it in GitHub Desktop.
Save loctanvo/d150db1fa98b400eb25e to your computer and use it in GitHub Desktop.
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