Hidden unique integers
In the town of Digitania, there lived a librarian named Lydia. She was not just any librarian; she had a unique gift for decoding hidden patterns and solving intricate puzzles hidden in texts. One day, Lydia received an ancient scroll from a distant land. The scroll contained a single string: "a123bc34d8ef34". The note attached to the scroll read: "Discover the unique treasures hidden within."
Lydia knew this was no ordinary string; it was a challenge meant for her. She sat at her desk, unfurled the scroll, and examined the string closely. Her task was to uncover the number of unique integers hidden within it.
We decide to help Lydia decode any scroll like that. In other words, we have to develop an algorithm that finds the number of different integers within a string between any characters. Two integers are considered different if their decimal representations without any leading zeros are different.
In a123bc34d8ef34
we find 123
, 8
and 34
, thus we should return 3.
Input Format
The first line contains , the number of strings to decode Then lines follows, containing all the strings
Constraints
- every string consists of positive integral numbers and lowercase letters
- every string is at most 1000 characters long
- every contiguous number fits 32bit size
Output Format
For each string, the number of unique integers within it
Sample Input 0
1
a123bc34d8ef34
Sample Output 0
3
Explanation 0
We find 123
, 8
, 34
and 34
. Since 34
is duplicated, it counts only as one. Thus the answer is 3
.
Sample Input 1
2
coding0145gym145rocks2024
abcdefghilmno
Sample Output 1
2
0
Explanation 1
0145
and 145
are the same number, then we find 2024
. Thus the answer is 2
.
The second string does not contain any numbers.
xxxxxxxxxx
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
-- Enter your code here. Read input from STDIN. Print output to STDOUT
end Solution