Be on time

Report a typo

You have a function that does its cleanups in half a second. And you need to run it 5 times to make an accurate decision. However, at the request of the customer, the result should be obtained in no more than two seconds.

Help the customer meet time requirements.

Sample Input 1:

Sample Output 1:

done
done
done
done
done
Write a program in Go
package main

import (
"fmt"
"time"
)

// please fix the code so we can finish in time
func doCleanUps() {
for range [5]struct{}{} {
cleanUp()
}
}

// DO NOT MODIFY this block of code
func main() {
start := time.Now()
defer func() {
if time.Since(start) > time.Second*2 {
fmt.Println("you're late!")
}
}()

doCleanUps()
time.Sleep(time.Second)
}
___

Create a free account to access the full topic