Kodewick
Start learning →
Basic←→0 / 70

Bus times

#023BasicLoopsSlices4 min

A bus comes every 15 minutes: the first at first minutes past the hour, the last no later than last. Write BusTimes(first, last) to return the minute of each bus in order (one at exactly last counts). If first is bigger than last, return an empty slice.

Examples
BusTimes(0, 45)→[0, 15, 30, 45]
BusTimes(10, 30)→[10, 25]
The functionfunc BusTimes(first, last int) []int
main.go
package main

func BusTimes(first, last int) []int {
	times := []int{}
	// your code here: for from first, adding 15 each time, putting each bus in times
	return times
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.