Guest User

Untitled

a guest
Feb 18th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "strings"
  6. )
  7.  
  8. func main() {
  9. s := "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
  10. firstOnly := make(map[int]struct{})
  11. for _, i := range []int{1, 5, 6, 7, 8, 9, 15, 16, 19} {
  12. firstOnly[i] = struct{}{}
  13. }
  14. result := make(map[string]int)
  15. for i, w := range strings.Split(s, " ") {
  16. var n int
  17. if _, ok := firstOnly[i+1]; ok {
  18. n = 1
  19. } else {
  20. n = 2
  21. }
  22. result[w[:n]] = i + 1
  23. }
  24. fmt.Println(result)
  25. }
Add Comment
Please, Sign In to add comment