
String-2-Matrix
You are given an unsorted string of unique (ignoring case) lower- and/or uppercase letters. Represent it as a correct mask for the square-arranged letters of the alphabet from "a" to "y" (row-major order). The mask must be a 5x5 matrix of integers as tuple of tuples with the following rule.
- character is not present in the string - use
0
in mask; - character is lowercase - use
1
; - character is uppercase - use
2
.
Here is a mission to make a reversed conversion - Matrix-2-String.
Input: String (str).
Output: Tuple of five tuples of five integers (int) each.
Examples:
assert converter("sMcigkqow") == ( (0, 0, 1, 0, 0), (0, 1, 0, 1, 0), (1, 0, 2, 0, 1), (0, 1, 0, 1, 0), (0, 0, 1, 0, 0), ) assert converter("acSyIwoQkumGe") == ( (1, 0, 1, 0, 1), (0, 2, 0, 2, 0), (1, 0, 1, 0, 1), (0, 2, 0, 2, 0), (1, 0, 1, 0, 1), )
Precondition:
- no "z" in string.