package main
import (
"fmt"
"strings"
)
func main() {
s := "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
firstOnly := make(map[int]struct{})
for _, i := range []int{1, 5, 6, 7, 8, 9, 15, 16, 19} {
firstOnly[i] = struct{}{}
}
result := make(map[string]int)
for i, w := range strings.Split(s, " ") {
var n int
if _, ok := firstOnly[i+1]; ok {
n = 1
} else {
n = 2
}
result[w[:n]] = i + 1
}
fmt.Println(result)
}
Comments