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

6 of 7
edited body
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, (削除) 30 (削除ここまで) 23 bytes

OIḟ0μAI©Ṡḟ0ṂṭḢṠ$μ®ḟ0ṠEṭ

Try it online! Or see the test cases

All upper or all lower.
Returns a flag list [D, F, S]:
D: clockwise = 1 / anticlockwise = -1
F: centrifugal = 1 / centripetal = -1
S: spinning = 1 / not spinning = 0

  • if S = 0 the other flags are still evaluated even though they carry no useful information.

###How?

OIḟ0μAI©Ṡḟ0ṂṭṠḢ$μ®ḟ0ṠEṭ - Main link: s
O - ordinals
 I - deltas (i.e. [a,b,c,...] -> [b-a,c-b,...])
 ḟ0 - filter out zeros
 - (call this Z)
 μ - start a new monadic chain (i.e. f(Z))
 A - absolute values
 I - deltas
 © - copy to register
 Ṡ - signs
 ḟ0 - filter out zeros
 Ṃ - minimum
 - (i.e. F = {centrifugal: 1; centripetal: -1})
 $ - last two links as a monad:
 Ḣ - head (Z)
 Ṡ - sign
 - (i.e. D = {clockwise: 1; anticlockwise: -1})
 ṭ - tack
 μ - start a new monadic chain (i.e. f([D,F]))
 ® - recall from register
 ḟ0 - filter out zeros
 Ṡ - signs
 E - all equal?
 - (i.e. S = {spinning: 1; not spinning: 0})
 ṭ - tack
 - (i.e. [D,F,S])
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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