B. Skibidus and Ohio
time limit per test1 second
memory limit per test256 megabytes
Skibidus is given a string s that consists of lowercase Latin letters. If s contains more than 1 letter, he can: Choose an index i
(1≤i≤|s|−1, |s| denotes the current length of s) such that si=si+1. Replace si with any lowercase Latin letter of his choice. Remove si+1 from the string.
Skibidus must determine the minimum possible length he can achieve through any number of operations.
Input
The first line contains an integer t (1≤t≤100) — the number of test cases.
The only line of each test case contains a string s (1≤|s|≤100). It is guaranteed s only contains lowercase Latin letters.
Output
For each test case, output an integer on the new line, the minimum achievable length of s
Answer
def cal(s)
l = s.squeeze.length
if l == s.length
return l
else
return 1
end
end
n = gets.to_i
for i in 1..n
s = gets.to_s.chomp
puts cal(s)
end