Ġ¬zḊḊ¬zĠȦȦ Main link. Argument: s (string) Ġ Group the indices of s by their corresponding elements. "abcba" -> [[1, 5], [2, 4], [3]] ¬ Take the logical NOT of each 1-based(!) index. [[1, 5], [2, 4], [3]] -> [[0, 0], [0, 0], [0]] Ḋ Dequeue; yield s without its fist element. "abcba" -> "bcba" z Zip-longest; zip the elements of the array to the left, using the string to the right as filler. ([[0, 0], [0, 0], [0]], "bcba") -> [[0, 0, 0], [0, 0, "bcba"]] ¬Ḋ TakeDequeue; remove the logicalfirst NOTarray of allthe zerosresult. and characters This yields an empty array if s does not contain duplicates. [[0, 0, 0], [0, 0, "bcba"]] -> [[1[[0, 10, 1]"bcba"]] ¬ Take the logical NOT of all zeros and characters. [[0, [10, "bcba"]] -> [[1, 1, [0, 0, 0, 0]]0]]] Ġ GridGroup. z Zip-longest. Since all arrays in the result to the left have the same number of elements, this is just a regular zip. [[1, 1, 1], [1, 1, [0, 0, 0, 0]]0]]] -> [[1, 1], [1, 1][[1], [1[1], [0[[0, 0, 0, 0]] Ȧ Any and all; test if the result is non-empty and contains no zeroes, at any depth. Yield 1 if so, 0 if not. [[1, 1], [1, 1][[1], [1[1], [0[[0, 0, 0, 0]] -> 0 Ȧ Any and all. 0 -> 0 Ġ¬zḊḊ¬zĠȦȦ Main link. Argument: s (string) Ġ Group the indices of s by their corresponding elements. "abcba" -> [[1, 5], [2, 4], [3]] ¬ Take the logical NOT of each 1-based(!) index. [[1, 5], [2, 4], [3]] -> [[0, 0], [0, 0], [0]] Ḋ Dequeue; yield s without its fist element. "abcba" -> "bcba" z Zip-longest; zip the elements of the array to the left, using the string to the right as filler. ([[0, 0], [0, 0], [0]], "bcba") -> [[0, 0, 0], [0, 0, "bcba"]] ¬ Take the logical NOT of all zeros and characters. [[0, 0, 0], [0, 0, "bcba"]] -> [[1, 1, 1], [1, 1, [0, 0, 0, 0]] Ġ Grid. z Zip-longest. Since all arrays in the result to the left have the same number of elements, this is just a regular zip. [[1, 1, 1], [1, 1, [0, 0, 0, 0]] -> [[1, 1], [1, 1], [1, [0, 0, 0, 0]] Ȧ Any and all; test if the result is non-empty and contains no zeroes, at any depth. Yield 1 if so, 0 if not. [[1, 1], [1, 1], [1, [0, 0, 0, 0]] -> 0 Ȧ Any and all. 0 -> 0 Ġ¬zḊḊ¬zĠȦȦ Main link. Argument: s (string) Ġ Group the indices of s by their corresponding elements. "abcba" -> [[1, 5], [2, 4], [3]] ¬ Take the logical NOT of each 1-based(!) index. [[1, 5], [2, 4], [3]] -> [[0, 0], [0, 0], [0]] Ḋ Dequeue; yield s without its fist element. "abcba" -> "bcba" z Zip-longest; zip the elements of the array to the left, using the string to the right as filler. ([[0, 0], [0, 0], [0]], "bcba") -> [[0, 0, 0], [0, 0, "bcba"]] Ḋ Dequeue; remove the first array of the result. This yields an empty array if s does not contain duplicates. [[0, 0, 0], [0, 0, "bcba"]] -> [[0, 0, "bcba"]] ¬ Take the logical NOT of all zeros and characters. [[0, 0, "bcba"]] -> [[1, 1, [0, 0, 0, 0]]] Ġ Group. z Zip-longest. Since all arrays in the result to the left have the same number of elements, this is just a regular zip. [[1, 1, [0, 0, 0, 0]]] -> [[1], [1], [[0, 0, 0, 0]] Ȧ Any and all; test if the result is non-empty and contains no zeroes, at any depth. Yield 1 if so, 0 if not. [[1], [1], [[0, 0, 0, 0]] -> 0 Ȧ Any and all. 0 -> 0 Jelly, 18 16 12 10 bytes
Ġ¬zḊḊ¬zĠȦȦ How it works
Ġ¬zḊḊ¬zĠȦȦ Main link. Argument: s (string) Ġ Group the indices of s by their corresponding elements. "abcba" -> [[1, 5], [2, 4], [3]] ¬ Take the logical NOT of each 1-based(!) index. [[1, 5], [2, 4], [3]] -> [[0, 0], [0, 0], [0]] Ḋ Dequeue; yield s without its fist element. "abcba" -> "bcba" z Zip-longest; zip the elements of the array to the left, using the string to the right as filler. ([[0, 0], [0, 0], [0]], "bcba") -> [[0, 0, 0], [0, 0, "bcba"]] ¬ Take the logical NOT of all zeros and characters. [[0, 0, 0], [0, 0, "bcba"]] -> [[1, 1, 1], [1, 1, [0, 0, 0, 0]] Ġ Grid. z Zip-longest. Since all arrays in the result to the left have the same number of elements, this is just a regular zip. [[1, 1, 1], [1, 1, [0, 0, 0, 0]] -> [[1, 1], [1, 1], [1, [0, 0, 0, 0]] Ȧ Any and all; test if the result is non-empty and contains no zeroes, at any depth. Yield 1 if so, 0 if not. [[1, 1], [1, 1], [1, [0, 0, 0, 0]] -> 0 Ȧ Any and all. 0 -> 0 Jelly, 18 16 12 10 bytes
Ġ¬zḊḊ¬zĠȦȦ How it works
Ġ¬zḊḊ¬zĠȦȦ Main link. Argument: s (string) Ġ Group the indices of s by their corresponding elements. "abcba" -> [[1, 5], [2, 4], [3]] ¬ Take the logical NOT of each 1-based(!) index. [[1, 5], [2, 4], [3]] -> [[0, 0], [0, 0], [0]] Ḋ Dequeue; yield s without its fist element. "abcba" -> "bcba" z Zip-longest; zip the elements of the array to the left, using the string to the right as filler. ([[0, 0], [0, 0], [0]], "bcba") -> [[0, 0, 0], [0, 0, "bcba"]] ¬ Take the logical NOT of all zeros and characters. [[0, 0, 0], [0, 0, "bcba"]] -> [[1, 1, 1], [1, 1, [0, 0, 0, 0]] Ġ Grid. z Zip-longest. Since all arrays in the result to the left have the same number of elements, this is just a regular zip. [[1, 1, 1], [1, 1, [0, 0, 0, 0]] -> [[1, 1], [1, 1], [1, [0, 0, 0, 0]] Ȧ Any and all; test if the result is non-empty and contains no zeroes, at any depth. Yield 1 if so, 0 if not. [[1, 1], [1, 1], [1, [0, 0, 0, 0]] -> 0 Ȧ Any and all. 0 -> 0