Repeated Numbers
Eren wants to decode a number.After lots of trial and error, he finally figured out that the number is a count of repeated single-digit integers.
Write a program to help Eren print the decoded number given a string of integers N.
Input
The first line contains a string of integers N.
Output
The output contains a single integer representing count of repeated numbers in the input.
Explanation
For N = 212311 ,
1 and 2 are repeated.Therefore, the output is 2.
Sample Input1
212311
Sample Output1
2
Sample Input2
111
Sample Output2
1
dict = {}
n = int(input())
while(n > 0):
tmp = n % 10
if dict.get(tmp) is None:
dict[tmp] = 1
else:
dict[tmp] = dict.get(tmp) + 1
n = int(n / 10)
count = 0
for key in dict.keys():
if dict[key] > 1:
count = count + 1
print(count)
Comments
Leave a comment