Beispiel #1
0
func main() {

	_, input := challengesutils.StdinReaderWithTestCases()

	for v := 0; v < len(input); v++ {

		//fmt.Println("========== Case ===============")
		haystackSize := strings.Split(input[v], " ")

		haystackRows, _ := strconv.Atoi(haystackSize[0])
		haystackOffset := v + haystackRows + 1

		haystack := append([]string{}, input[v+1:haystackOffset]...)

		//fmt.Printf("Haystack: %v \n", haystack)

		needleSize := strings.Split(input[v+haystackRows+1], " ")
		needleRows, _ := strconv.Atoi(needleSize[0])

		needleOffset := v + haystackRows + 2
		needle := append([]string{}, input[needleOffset:needleRows+needleOffset]...)

		//fmt.Printf("Needle: %v \n", needle)

		if searchIn(haystack, needle) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		v += needleRows + haystackRows + 1

	}
}
func main() {
	_, input := challengesutils.StdinReaderWithTestCases()
	for _, word := range input {
		if challengesutils.IsPalindrome(word) {
			fmt.Println("-1")
		} else {
			for i, _ := range word {
				wordb := word[0:i] + word[i+1:len(word)]
				if challengesutils.IsPalindrome(wordb) {
					fmt.Printf("%v\n", i)
					break
				}
			}
		}
	}
}
Beispiel #3
0
func main() {
	_, input := challengesutils.StdinReaderWithTestCases()

	const minLetter = 97

	for _, word := range input {

		j := len(word) - 1
		ticks := 0

		for i := 0; i <= j; i++ {
			if word[i] != word[j] {
				charA := int(word[i])
				charB := int(word[j])
				ticks += int(math.Abs(float64(charA) - float64(charB)))
			}
			j--
		}

		fmt.Printf("%v\n", ticks)
	}
}