Programming challenge description:
a number is a self-describing number when (assuming digit positions are labeled 0 to n-1), the digit in each position is equal to the number of times that that digit appears in the number.
input:
your program should read lines of text from standard input. each line contains a single positive integer, n.
output:
for each input n, print 1 to standard output if n is a self-describing number. otherwise, print 0.
for the curious, here''s how 2020 is a self-describing number: position 0 has value 2 and there are two 0s in the number. position 1 has value 0 because there are no 1's in the number. position 2 has value 2 and there are two 2's. and the position 3 has value 0 and there are zero 3's.
test 1
test input
2020
expected output
1
test 2
test input
22
expected output
1
test 2
test input
22
expected output
0
test 3
test input
1210
expected output
1