#P1125. Lucky Word Checker
Lucky Word Checker
Lucky Word Checker
The problem is about determining if a given word is a Lucky Word based on the frequency of its letters. For each word, let \(\text{maxn}\) be the highest frequency of any letter and \(\text{minn}\) be the lowest frequency among the letters that appear in the word. If \(\text{maxn} - \text{minn}\) is a prime number, then the word is considered a Lucky Word.
More formally, given a word, compute the frequencies of all characters (only consider characters that actually appear in the word). Let \(\text{maxn}=\max(frequency)\) and \(\text{minn}=\min(frequency)\). If \(\text{maxn} - \text{minn}\) is prime (i.e. greater than 1 and divisible only by 1 and itself), then output Lucky Word; otherwise, output Not Lucky Word.
inputFormat
The input consists of multiple test cases. The first line contains an integer \(T\) (\(1 \leq T \leq 100\)), representing the number of test cases. Each of the following \(T\) lines contains a single word consisting of only lowercase English letters.
outputFormat
For each test case, output a single line: Lucky Word if the difference between the maximum and minimum letter frequency is a prime number, otherwise output Not Lucky Word.
sample
1
hello
Not Lucky Word
</p>