package internal

import (
	"math/rand/v2"
	"sort"
)

type Dictionary []string

func (d Dictionary) GetRandomWord() string {
	return d[rand.IntN(len(d))]
}

func (d Dictionary) GetRandomWords(n int) []string {
	r := make([]string, n)

	for i := range r {
		r[i] = d[rand.IntN(len(d))]
	}

	return r
}

func (d Dictionary) Contains(word string) bool {
	index := sort.SearchStrings(d, word)
	return index < len(d) && d[index] == word
}
