Skip to content

Instantly share code, notes, and snippets.

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