Kodewick
Start learning →
Starter←→0 / 70

Bean sprout

#019StarterLoops3 min

The bean sprout is 2 cm tall and grows 3 cm a day. Write DaysToGrow(target): how many days until it is target cm or taller? If it is tall enough already, that's 0 days.

Examples
DaysToGrow(8)→2
DaysToGrow(2)→0
The functionfunc DaysToGrow(target int) int
main.go
package main

func DaysToGrow(target int) int {
	height := 2
	days := 0
	// your code here: while not tall enough: grow 3 cm and add a day
	return days
}
Ctrl + Enter runs too
Result

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