...
/Solution Review: Coroutine to Compute Running Maximum
Solution Review: Coroutine to Compute Running Maximum
The solution to the 'Coroutine to Compute Running Maximum' challenge.
We'll cover the following...
Press + to interact
import mathdef maximum():result = - math.infwhile True:value = yield result # Recieving valuesif value > result: # Deciding on maximumresult = valuecoroutine = maximum()next(coroutine)# Sending valuesprint(coroutine.send(1))print(coroutine.send(7))print(coroutine.send(3))print(coroutine.send(10))print(coroutine.send(5))print(coroutine.send(8))print(coroutine.send(12))coroutine.close() # Closing coroutine
Explanation
Look at line 4 ...
Access this course and 1400+ top-rated courses and projects.