Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Code Challenege
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Data; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static List<int> Integers {get;set;} public static void Main(string[] args) { Initialize(100, 0, 100); // Validation.TestIt(); //Your code goes here } public static void Initialize(int numberOfItems, int min, int max) { Integers = new List<int>(); var rnd = new Random(); for(var i=0; i < numberOfItems; i++) { var newNum = rnd.Next(min, max); Integers.Add(newNum); } } public static void PrintIt(List<int> ints) { for(var i=0; i < ints.Count(); i++) { var n = ints[i]; Console.Write(n); if (i < ints.Count() - 1) { Console.Write(", "); } } Console.WriteLine(""); Console.WriteLine("Done!"); } } /* public static class Validation { public static void TestIt() { var a = new int[]{21, 64, 88, 88, 9, 72, 86, 48, 5, 21, 95, 75, 99, 87, 89, 13, 60, 13, 23, 85, 39, 86, 81, 57, 48, 64, 27, 28, 83, 27, 75, 51, 69, 48, 35, 90, 1, 26, 35, 10, 35, 78, 49, 31, 36, 71, 21, 98, 68, 37, 2, 75, 28, 32, 45, 34, 82, 31, 40, 45, 44, 57, 65, 77, 45, 43, 5, 51, 52, 99, 11, 34, 78, 12, 49, 60, 37, 50, 20, 76, 42, 28, 60, 45, 25, 0, 23, 36, 2, 0, 8, 70, 86, 90, 65, 77, 13, 71, 86, 93}; var aExpectation = new int[]{0, 1, 2, 5, 8, 9, 10, 11, 12, 13, 20, 21, 23, 25, 26, 27, 28, 31, 32, 34, 35, 36, 37, 39, 40, 42, 43, 44, 45, 48, 49, 50, 51, 52, 57, 60, 64, 65, 68, 69, 70, 71, 72, 75, 76, 77, 78, 81, 82, 83, 85, 86, 87, 88, 89, 90, 93, 95, 98, 99}; var aResult = a.MyDistinct<int>(); var aSuccess = aResult.Count() == aExpectation.Count() && !aResult.Except(aExpectation).Any(); var l = new List<int>{21, 64, 88, 88, 9, 72, 86, 48, 5, 21, 95, 75, 99, 87, 89, 13, 60, 13, 23, 85, 39, 86, 81, 57, 48, 64, 27, 28, 83, 27, 75, 51, 69, 48, 35, 90, 1, 26, 35, 10, 35, 78, 49, 31, 36, 71, 21, 98, 68, 37, 2, 75, 28, 32, 45, 34, 82, 31, 40, 45, 44, 57, 65, 77, 45, 43, 5, 51, 52, 99, 11, 34, 78, 12, 49, 60, 37, 50, 20, 76, 42, 28, 60, 45, 25, 0, 23, 36, 2, 0, 8, 70, 86, 90, 65, 77, 13, 71, 86, 93}; var lExpectation = new List<int>{0, 1, 2, 5, 8, 9, 10, 11, 12, 13, 20, 21, 23, 25, 26, 27, 28, 31, 32, 34, 35, 36, 37, 39, 40, 42, 43, 44, 45, 48, 49, 50, 51, 52, 57, 60, 64, 65, 68, 69, 70, 71, 72, 75, 76, 77, 78, 81, 82, 83, 85, 86, 87, 88, 89, 90, 93, 95, 98, 99}; var lResult = l.MyDistinct<int>(); var lSuccess = lResult.Count() == lExpectation.Count() && !lResult.Except(lExpectation).Any(); var m = new List<string>{"n", "b", "e", "foo", "world", "a", "d", "h", "f", "d", "a", "s", "s", "f", "b", "foo", "hello"}; var mExpectation = new List<string>{"a", "b", "d", "e", "f", "foo", "h", "hello", "n", "s", "world"}; var mResult = m.MyDistinct<string>(); var mSuccess = mResult.Count() == mExpectation.Count() && !mResult.Except(mExpectation).Any(); Console.WriteLine(""); if (!(aSuccess && lSuccess && mSuccess)) { Console.WriteLine("There was a test failure"); } else { Console.WriteLine("All Tests Pass"); } } } */ }
run
|
edit
|
history
|
help
0
Array Foreach with sum
7.2 Creating async methods the old way
Test equality...2
Date format display
ö1
AnonymousFunction (demo)
remove special char
Group by Example
decimal to binary
asdxasxasdf