source and goal of the same length and an integer parts.
The string source is cut into parts consecutive pieces of equal length. The pieces may then be put in any order and glued back together. Letters inside a piece cannot be moved.
Return True if this can produce exactly goal, and False otherwise.source="xyzxyw", goal="xywxyz", parts=2 → True
Cut source into 2 pieces of 3 letters: "xyz" and "xyw". Swapping them gives "xywxyz".
source="abab", goal="baab", parts=2 → False
The pieces are "ab" and "ab", and any order of them gives only "abab".
source="pqr", goal="rqp", parts=3 → True
partssource="xyzxyw", goal="xywxyz", parts=2
True
Run checks the first 3 tests in your browser. Submit checks all 45 tests on the server, hidden ones included.