Skip to content

Instantly share code, notes, and snippets.

@Vovanda
Last active May 19, 2021 20:09
Show Gist options
  • Save Vovanda/51018532c75ce4ef4d84340dc5d7e42b to your computer and use it in GitHub Desktop.
Save Vovanda/51018532c75ce4ef4d84340dc5d7e42b to your computer and use it in GitHub Desktop.
using System;
var rnd = new Random(Guid.NewGuid().GetHashCode());
Func<int, bool> predicat = x => x > 3;
var arr = new[] {1, 3, 7, 4, 5};
var check = new bool[arr.Length];
int count = arr.Length;
while(count > 0)
{
int index = rnd.Next(arr.Length);
if(!check[index])
{
if(predicat(arr[index]))
{
Console.WriteLine(arr[index]);
}
count--;
check[index] = true;
}
}
Console.WriteLine("Done!");
{
"version": 1,
"target": "Run",
"mode": "Debug"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment