c# fully arranged algorithm