Skip to main content
the way +x ("flip") works has changed. editing with coltim's permission: https://chat.stackexchange.com/transcript/message/59077142#59077142
Source Link
ngn
  • 15.6k
  • 2
  • 45
  • 90

K (ngn/k)K (ngn/k), 19 17 1721 bytes

1+?{(++(#x)#',\x)?x}',\ 

Try it online!Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++(#x)#',\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 17 bytes

1+?{(++,\x)?x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 17 21 bytes

1+?{((#x)#',\x)?x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • ((#x)#',\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices
deleted 3 characters in body
Source Link
coltim
  • 6.2k
  • 8
  • 13

K (ngn/k), 19 17 bytes

1+?{(++,\x)?x}',\ 

Try it online!Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 17 bytes

1+?{(++,\x)?x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 17 bytes

1+?{(++,\x)?x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices
added 6 characters in body
Source Link
coltim
  • 6.2k
  • 8
  • 13

K (ngn/k), 1919 17 bytes

1+?{*(++,\x)?,x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • *(...)?,x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 bytes

1+?{*(++,\x)?,x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • *(...)?,x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices

K (ngn/k), 19 17 bytes

1+?{(++,\x)?x}',\ 

Try it online!

Modeled after @Jonah's J answer.

  • {...}',\ for each prefix of the (implicit) input...
  • (++,\x) expand each prefix (of the current passed-in prefix) to the full length of that prefix (e.g., transform 1 1 2 from (1;1 1;1 1 2) into (1 1 1;1 1 1;1 1 2))
  • (...)?x get the index of the first transformed prefix that matches the prefix itself
  • 1+?{...} add one to the distinct indices
Source Link
coltim
  • 6.2k
  • 8
  • 13
Loading