Skip to main content
deleted 2 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

K (ngn/k), 15 bytes

{x@.=+|\2\!-#x} 

Try it online!

x:"abcdefg" !-#x / integers from -length-1 to -1 -7 -6 -5 -4 -3 -2 -1 2\!-#x / convert to base 2 -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 |\2\!-#x / maximum scan -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 .=+|\2\!-#x / group identical columns (,0; 1 2; 3 4 5 6) x@.=+|\2\!-#x / index back into the input string (,"a"; "bc"; "defg") 

K (ngn/k), 15 bytes

{x@.=+|\2\!-#x} 

Try it online!

x:"abcdefg" !-#x / integers from -length-1 to -1 -7 -6 -5 -4 -3 -2 -1 2\!-#x / convert to base 2 -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 |\2\!-#x / maximum scan -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 .=+|\2\!-#x / group identical columns (,0; 1 2; 3 4 5 6) x@.=+|\2\!-#x / index back into the input string (,"a"; "bc"; "defg") 

K (ngn/k), 15 bytes

{x@.=+|\2\!-#x} 

Try it online!

x:"abcdefg" !-#x / integers from -length to -1 -7 -6 -5 -4 -3 -2 -1 2\!-#x / convert to base 2 -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 |\2\!-#x / maximum scan -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 .=+|\2\!-#x / group identical columns (,0; 1 2; 3 4 5 6) x@.=+|\2\!-#x / index back into the input string (,"a"; "bc"; "defg") 
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

K (ngn/k), 15 bytes

{x@.=+|\2\!-#x} 

Try it online!

x:"abcdefg" !-#x / integers from -length-1 to -1 -7 -6 -5 -4 -3 -2 -1 2\!-#x / convert to base 2 -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 |\2\!-#x / maximum scan -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 .=+|\2\!-#x / group identical columns (,0; 1 2; 3 4 5 6) x@.=+|\2\!-#x / index back into the input string (,"a"; "bc"; "defg")