generate functionThu, 22 Dec 2022

write a function to receive a whole number and return true if the digits are in ascending order from right to left

bool IsAscending(int i) { return i.ToString() .Reverse() .Select(x => int.Parse(x.ToString())) .Zip(new[] { 1 }.Concat( i.ToString() .Reverse() .Skip(1) .Select(x => int.Parse(x.ToString()))), (x, y) => x >= y) .All(x => x); }

Questions about programming?Chat with your personal AI assistant