code consists of digits. Call it **self-describing** if, for every position i (0-based), the digit code[i] equals how many times the digit i appears in the whole of code.
For example, in "3211000": position 0 holds 3, and 0 appears three times; position 1 holds 2, and 1 appears twice; position 2 holds 1, and 2 appears once; and so on.
Return True if code is self-describing, and False otherwise.code="2020" → True
There are two 0s, no 1s, two 2s and no 3s — exactly what positions 0, 1, 2, 3 say.
code="21200" → True
Two 0s, one 1, two 2s, no 3s and no 4s — everything matches.
code="11" → False
Position 0 says 1, but the code contains no 0 at all.
code consists of digits onlycode="2020"
True
Run checks the first 3 tests in your browser. Submit checks all 140 tests on the server, hidden ones included.