Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

8 of 17
deleted 1437 characters in body
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, (削除) 43 41 40 (削除ここまで) 18 bytes

3RŒḄIṙ
4RÇ€
OIṠ¢e@

TryItOnline
Or all test cases

###How?

An infinity word has:

  1. the same first and last letter;
  2. length 5;
  3. no equal letters next to each other;
  4. sum of its four alphabet deltas equal to zero;
  5. sum of its four alphabet deltas signs equal to zero;
  6. two positive alphabet deltas or two negative alphabet deltas in a row.

This can all be boiled down to a condition that the alphabet delta signs are some rotation of [1,1,-1,-1] (where the sign of 0 is 0)

###How?

3RŒḄIṙ - Link 1, make a rotation of [1,1,-1,-1]: n
3R - range(3) -> [1,2,3]
 ŒḄ - bounce -> [1,2,3,2,1]
 I - increments -> [1,1,-1,-1]
 ṙ - rotate left by n (e.g. n=1 -> [1,-1,-1,1])
4RÇ€ - Link 2, make the four rotations of [1,1,-1,-1] (no arguments, AKA niladic)
4R - range(4) -> [1,2,3,4]
 Ç€ - call the last link as a monad for €ach
OIṠ¢e@ - Main link: word
O - cast to ordinals
 I - increments - the alphabet deltas
 Ṡ - sign
 e@ - exists in (@ = reversed arguments)
 ¢ - call last link as a nilad
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

AltStyle によって変換されたページ (->オリジナル) /