Quick actions

cmd+k|ctrl+k

Navigation

Languages

100knock #01

Snippet info

Language

Go

Visibility

public

Author

re3turn

Created

2018-05-08T14:43:40Z

Updated

2018-05-08T14:50:03Z

package main

import (
	"fmt"
	"unicode/utf8"
)

func oddWord(word string) string {
	length := utf8.RuneCountInString(word)/2 + (utf8.RuneCountInString(word) % 2)
	str := make([]rune, length)
	i := 0
	for index, runeValue := range word {
		if index%2 == 1 {
			str[i] = runeValue
			i++
		}
	}

	return string(str)
}

func main() {
	word := "パタトクカシーー"

	fmt.Println(oddWord(word))
}
INFO