
v0.40: Create exercises. Challenge the community.
Meet Studio →Write a function named identity that accepts a string str.
The function must generate and print all numeric sequences of the exact same
length as str that satisfy the identity matrix rule for str:
- The digit at position i of the output sequence must strictly equal the
total number of times the character str[i] appears anywhere inside that
printed sequence itself.
- The arithmetic sum of all digits in the sequence must be equal to the length
of str.
If str length is greater than 10, or if no valid sequence exists, the function
must print nothing.
Multiple valid sequences must be printed in ascending numerical order, each
followed by a newline (\n).
identity("0123456");Expected result
3211000For your own tracking. Tests grade your code.
identity("3210");Expected result
0121
0202identity("9999999999");Expected result
(empty result)
Expected files
identity.cAllowed functions
writeAllowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.