package day06

import (
	_ "fmt"
	"sort"
	"strings"

	"github.com/mpvl/unique"
)

func Part1(input string) int {
	for i:=4;i<len(input);i++ {
		s := input[i-4:i]
		if s[0] == s[1] || s[0] == s[2] || s[0] == s[3] || s[1] == s[2] || s[1] == s[3] || s[2] == s[3] {
			continue
		} else {
			return i
		}
	}
	return 0
}

func Part2(input string) int {
	for i:=14;i<len(input);i++ {
		s := input[i-14:i]
		sSlice := strings.Split(s,"")
		length := len(sSlice)
		sort.Strings(sSlice)
		unique.Strings(&sSlice)
		if length == len(sSlice) {
			return i
		}
	}
	return 0
}
