Skip to main content
added 1308 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Ġ¬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 
added 1308 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 18 16 12 10 bytes

Ġ¬zḊḊ¬zĠȦȦ 

Try it online!

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ĠȦȦ 

Try it online!

Jelly, 18 16 12 10 bytes

Ġ¬zḊḊ¬zĠȦȦ 

Try it online!

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 
added 8 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 18 16 1212 10 bytes

ĠIz0Ȧ ĠIz0ȦĠ¬zḊḊ¬zĠȦȦ 

Try it online!Try it online!

Jelly, 18 16 12 bytes

ĠIz0Ȧ ĠIz0Ȧ 

Try it online!

Jelly, 18 16 12 10 bytes

Ġ¬zḊḊ¬zĠȦȦ 

Try it online!

added 27 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
deleted 7 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading