映画館の座席表は 1 列につき 1 つの文字列です。. は空席、x は予約済みです。need 人で同じ列に座りたいとします(となり同士でなくてかまいません)。RowForFriends(rows, need) を書いて、空席が足りる最初の列の番号(1 から数える)を返しましょう。どの列も足りなければ 0 です。
RowForFriends([]string{"xx.x", "..x.", "...."}, 3)→2RowForFriends([]string{"xxx", "x.x"}, 2)→0func RowForFriends(rows []string, need int) intpackage main
func RowForFriends(rows []string, need int) int {
for i, row := range rows {
free := 0
// ここにコードを書く:この列の席を range で回し、'.' ごとに free に 1 を足す
// ここにコードを書く:空席が足りる?なら列の番号を返す
}
return 0
}
実行すると例で試せます。よさそうなら提出しましょう。