#P10906. Valid Password Substrings Count
Valid Password Substrings Count
Valid Password Substrings Count
Given a string, count the number of distinct substrings (distinct by their starting and ending positions) that can serve as a valid password according to the following rules:
- The length must be between $$8$$ and $$16$$ characters (inclusive).
- The substring must contain at least one digit (0-9) and at least one symbol (any character that is not an alphanumeric letter).
For example, lanqiao2024!
, +-*/0601
, and 8((>w<))8
are valid passwords, while 12345678
, ##**##**
, abc0!#
, and lanqiao20240601!?
are not valid.
Your task is to count how many substrings of the given input string satisfy these conditions. Two substrings are considered different if their starting or ending indices in the original string are different.
inputFormat
A single line of text representing the input string.
outputFormat
An integer representing the total number of valid substrings (passwords) that satisfy the above conditions.
sample
a1#aaaaa
1