Kodewick
Start learning →
Basic←→0 / 70

Rain chart

#069BasicSlicesStrings4 min

The little weather station noted five days of rain (in mm). Show one line a day: the day, a space, then as many # as the rain, like Mon ###. The starter already prints the lines; you build bar.

Should show
Mon ###
Tue #
Wed #####
Thu ##
Fri ####
main.go
package main

import "fmt"

var days = []string{"Mon", "Tue", "Wed", "Thu", "Fri"}
var rain = []int{3, 1, 5, 2, 4}

func main() {
	for i := range days {
		bar := ""
		// your code here: add as many "#" to bar as rain[i] says
		fmt.Println(days[i], bar)
	}
}
Ctrl + Enter runs too
Result

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