Challenge 1: A Flow with Operators — Solution import kotlinx.coroutines.* import kotlinx.coroutines.flow.* fun numberStream(): Flow = flow { for (i in 1..5) { delay(200) emit(i) } } fun main() = runBlocking { numberStream() .filter { it % 2 == 0 } .map { it * it } .collect { println(it) } } /* Output (roughly one per 200ms as the underlying flow emits): 4 16 Notes: - numberStream() emits 1, 2, 3, 4, 5 one at a time, each after a 200ms delay, since flow { } only runs when collect() is called. - filter { it % 2 == 0 } keeps only 2 and 4 as they come through. - map { it * it } squares each of those: 2 -> 4, 4 -> 16. - Because Flow is cold and processes values one at a time as they're emitted, the operators apply to each value individually as it flows through, rather than waiting for the whole stream to finish first. */