Pure StorageOA #5
Compute Number Score
Estimated EasyJudge-ready
Topics (AI-labelled)StringsSimulation
Compute the score of a positive integer n from its decimal representation; the following independent rules may score the same digit more than once: add 2 for each digit 5; add 4 for each pair of adjacent digits 33; for each maximal run in which each digit is exactly 1 greater than the previous one, add L², where L is the run length; add 6 if n is divisible by 5; add 1 for each odd digit.
Input
One line containing a positive decimal integer with no sign and no leading zeros. Added by this site: at most 100000 digits.
Output
Output the total score.
Example 1
Input:
5
Output:
10
Example 2
Input:
12345
Output:
36
Example 3
Input:
3333
Output:
20
Editorial
Loading solution…