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 Answer

Commonmark migration
Source Link

Jelly, (削除) 43 41 40 25 24 23 22 21 14 (削除ここまで) 13 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

-1 Thanks to Kevin Cruijssen (use of previously unavailable nilad Ø2 which yields [2,2])

=ṚḢȧOIṠIIA=Ø2

TryItOnline
Or all test cases (plus "RULES")

###How?

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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

How?

=ṚḢȧOIṠIIA=Ø2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 Ø2 - literal [2,2]
 = - equals? (non-vectorising version)

Jelly, (削除) 43 41 40 25 24 23 22 21 14 (削除ここまで) 13 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

-1 Thanks to Kevin Cruijssen (use of previously unavailable nilad Ø2 which yields [2,2])

=ṚḢȧOIṠIIA=Ø2

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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

=ṚḢȧOIṠIIA=Ø2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 Ø2 - literal [2,2]
 = - equals? (non-vectorising version)

Jelly, (削除) 43 41 40 25 24 23 22 21 14 (削除ここまで) 13 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

-1 Thanks to Kevin Cruijssen (use of previously unavailable nilad Ø2 which yields [2,2])

=ṚḢȧOIṠIIA=Ø2

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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

How?

=ṚḢȧOIṠIIA=Ø2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 Ø2 - literal [2,2]
 = - equals? (non-vectorising version)
added 85 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, (削除) 43 41 40 25 24 23 22 21 14 (削除ここまで) 1413 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

-1 Thanks to Kevin Cruijssen (use of previously unavailable nilad Ø2 which yields [2,2])

=ṚḢȧOIṠIIA=2,2=ṚḢȧOIṠIIA=Ø2

TryItOnline TryItOnline
Or all test cases 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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

=ṚḢȧOIṠIIA=2,2=ṚḢȧOIṠIIA=Ø2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 2,2Ø2 - literal [2,2]
 = - equals? (non-vectorising version)

Jelly, (削除) 43 41 40 25 24 23 22 21 (削除ここまで) 14 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

=ṚḢȧOIṠIIA=2,2

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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

=ṚḢȧOIṠIIA=2,2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 2,2 - literal [2,2]
 = - equals? (non-vectorising version)

Jelly, (削除) 43 41 40 25 24 23 22 21 14 (削除ここまで) 13 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

-1 Thanks to Kevin Cruijssen (use of previously unavailable nilad Ø2 which yields [2,2])

=ṚḢȧOIṠIIA=Ø2

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) and (equivalently) (4) 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)

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

=ṚḢȧOIṠIIA=Ø2 - Main link: word
 Ṛ - reverse word
= - equals? (vectorises)
 Ḣ - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
 Ṡ - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A - absolute value (vectorises)
 Ø2 - literal [2,2]
 = - equals? (non-vectorising version)
deleted 52 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, (削除) 43 41 40 25 24 23 22 21 (削除ここまで) 2114 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

9BḤ’ṙ4R¤
0ị=1ị$aOIṠe¢=ṚḢȧOIṠIIA=2,2

TryItOnline TryItOnline
Or all test cases all test cases (plus "RULES")

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

9BḤ’ṙ4R¤ - Link 1=ṚḢȧOIṠIIA=2, make the four rotations of2 [1,1,-1,-1] (no arguments,Main AKAlink: niladic)word
9B - 9 converted to binary  -> [ 1, 0, 0, 1]
  - double (vectorises)reverse word
= -> [ 2, 0, 0, 2]
   - decrementequals? (vectorises) -> [ 1,-1,-1, 1]
 ¤ - nilad followed by link(s) as a nilad
 4R - head range(4) -> [ 1, is the 2,first character equal to the last?)
 ȧ 3, - 4]and
 - rotate left by O -> [[-1,-1,1,1],[-1,1,1,-1],[1,1,-1,-1],[1,-1,-1,1]]
0ị=1ị$aOIṠe¢ - Main link:cast word
 $  to ordinals
 - lastI two links as a monad
0ị - increments - the alphabet deltas (or -just element[] atif index1st 0!= (last character)
 =  - equals?
 1ị - element at index 1sign (first charactervectorises)
 a  - and
  I O - increments - castdeltas wordof tothose ordinalssigns
 I - increments - thedeltas alphabetof deltasthose
 A  - signabsolute value (vectorises)
 e 2,2 - existsliteral in[2,2]
 = ¢ - call last- linkequals? (1) as anon-vectorising niladversion)

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

9BḤ’ṙ4R¤
0ị=1ị$aOIṠe¢

TryItOnline
Or all test cases (plus "RULES")

###How?

9BḤ’ṙ4R¤ - Link 1, make the four rotations of [1,1,-1,-1] (no arguments, AKA niladic)
9B - 9 converted to binary  -> [ 1, 0, 0, 1]
  - double (vectorises) -> [ 2, 0, 0, 2]
   - decrement (vectorises) -> [ 1,-1,-1, 1]
 ¤ - 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)
 a  - and
  O - cast word to ordinals
 I - increments - the alphabet deltas
  - sign (vectorises)
 e - exists in
 ¢ - call last link (1) as a nilad

Jelly, (削除) 43 41 40 25 24 23 22 21 (削除ここまで) 14 bytes

-7 bytes thanks to fireflame241 (0ị=1ị$->=ṚḢ and use of IIA=2,2 to test for the 4 rotations)

=ṚḢȧOIṠIIA=2,2

TryItOnline
Or all test cases (plus "RULES")

fireflame241 noted that this is then equivalent to the deltas of the deltas of the alphabet delta signs being in [[2,2],[2,-2],[-2,2],[-2,-2]] which may be tested by the absolute values being equal to [2,2]!

###How?

=ṚḢȧOIṠIIA=2,2 - Main link: word
  - reverse word
= - equals? (vectorises)
  - head (is the first character equal to the last?)
 ȧ - and
 O - cast word to ordinals
 I - increments - the alphabet deltas (or just [] if 1st != last)
  - sign (vectorises)
 I - increments - deltas of those signs
 I - increments - deltas of those
 A  - absolute value (vectorises)
 2,2 - literal [2,2]
 = - equals? (non-vectorising version)
added 20 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
edited body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
edited body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
added 28 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
added 8 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
deleted 1437 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
deleted 1437 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
deleted 1437 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
deleted 12 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
deleted 12 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
added 125 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
added 125 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
added 125 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading

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