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

11 of 17
added 28 characters in body
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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

3RŒḄIμṙ4R¤
0ị=1ị$aOIṠ¢e@

TryItOnline
Or all test cases (plus "RULES")

###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.

All but (1) may 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μṙ4R¤ - Link 1, make the four rotations of [1,1,-1,-1] (no arguments, AKA niladic)
3R - range(3) -> [1,2,3]
 ŒḄ - bounce -> [1,2,3,2,1]
 I - increments -> [1,1,-1,-1]
 μ - monadic chain separation
 ¤ - nilad followed by link(s) as a nilad
 4R - range(4) -> [1,2,3,4]
 ṙ - rotate left by -> [[1,-1,-1,1],[-1,-1,1,1],[-1,1,1,-1],[1,1,-1,-1]]
0ị=1ị$aOIṠ¢e@ - Main link: word
 $ - last two links as a monad
0ị - element at index 0 (last character)
 = - equals?
 1ị - element at index 1 (first character)
 O - cast to ordinals
 I - increments - the alphabet deltas
 Ṡ - sign
 e@ - exists in (@ = reversed arguments)
 ¢ - call last link (2) as a nilad
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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