Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second: not a one-liner, but stepping through the list with next() to try and fail fast solution in Speedy category for Ascending List by leggewie
def is_ascending(items) -> bool:
if len(items) < 2: return True # The easiest and fastest to test for immediate resolution
a = iter(items)
x = next(a)
y = next(a)
# while we step through the list, we can abort and immediately return "False"
# upon the first encounter where a successor in the list isn't strictly larger
while x < y:
try:
x = y
y = next(a)
except StopIteration:
return True
return False
May 25, 2021
Comments: