Integrity Score
Frequency: Reported
A network security analyst must verify the integrity of data transmitted over a secure network. Each data packet consists of a string of characters, and each character has been assigned a numerical value according to a predetermined mapping.
The integrity score of a data packet is the number of nonempty substrings for which the sum of the numerical values of the characters is divisible by the substring's length. Return that count.
Mapping preserved in the source
The screenshot visibly preserves the following portion of the mapping:
| Letter | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | 1 | 1 | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4 | 5 | 5 | 5 | 6 | 6 |
The right side of the table is cropped from the source screenshot. The worked example separately establishes that y maps to 9. Do not infer the omitted entries from this file alone.
Example
For dataPacket = "hey", the nonempty substrings are:
"h": sum3, divisible by length1."e": sum2, divisible by length1."y": sum9, divisible by length1."he": sum3 + 2 = 5, not divisible by length2."hey": sum3 + 2 + 9 = 14, not divisible by length3."ey": sum2 + 9 = 11, not divisible by length2.
Therefore, return 3.
Function
integrityScore(string dataPacket) -> intdataPacketis a string of lengthn.- Return the number of nonempty substrings that meet the criterion.
No numeric constraints were visible in the recovered screenshot.