Useful algorithms I wrote learning C#