Outsmart the boffins at New Scientist (string rotation) The brainiacs at New Scientist tweeted this morning that &quot;The word STABLE has the neat property that you can cycle the first letter to the end to make a new word: TABLES. And you can do it again to make ABLEST.&quot; (https://twitter.com/newscientist/status/1379751396271124480)
This is of course correct. It is not, however, unique. Let us demonstrate that we can use computational force to match their linguistic cleverness.
You are to write a program that generates two sets of outputs based on the dictionary words revealed when rotating the letters of another dictionary word. Using the dictionary at https://gist.githubusercontent.com/wchargin/8927565/raw/d9783627c731268fb2935a731a618aa8e95cf465/words,

find all the dictionary words with more than two characters for which every possible rotation yields another dictionary word. Show only one example of each rotation set (so, for example, show only one of &quot;car&quot;, &quot;arc&quot;, and &quot;rca&quot;).
find the words for which the largest number of valid rotations exist. You should find multiple words that tie with the same number of valid rotations. As above, show only one member of each set.

Additional rules:

You can assume that the dictionary has been downloaded outside your code, and can be passed to your code as input or in a variable.

If you need to process the word list to put it in a format more
natural for your programming language (a list for example), you may
exclude this code from your byte count. However this process should
not remove any words; any bytes associated with, for example,
removing two-letter and one-letter words from the dictionary must be
included in your byte total.

Anything in the words list counts as a word, even if we know it's
really an acronym, or contains punctuation marks, or is not English (e.g. &quot;AOL&quot; or &quot;Abdul's&quot;). Treat all characters as letters.

Treat all letters as identically cased (so &quot;India&quot; and &quot;india&quot; are
the same, and &quot;eAt&quot; is a valid word).

No shortcuts based on already knowing the answer, or knowing the maximum number of rotations. Your code needs to actually solve for that.


Using these rules and some ungolfed Wolfram Language, I found four completely rotateable words and 15 words tied at the level of maximum rotateability. This is a code golf challenge, and I imagine it won't be hard to do it more concisely than I did. I plan to call out any particularly creative solutions as well, regardless of length.
--
Intended output (assuming I coded it correctly)
completely rotatable words: aol, arc, asp, eat
(each of these words can be presented with the letters in any rotation)
maximum rotatable words: all of the words above, plus
ablest, alan, ales, anal, ankh, aver, emit, ernst, errant, evan, evil
(each of this latter group also has two valid rotations)
Python 3, 269 266 bytes

def f(a,m=0,b=[],c=[]):
 a=[k.lower()for k in a]
 while a:
  w,k,u=a[0],[],1
  for i in range(len(w)):
   x=w[i:]+w[:i]
   u,k=x in a and(u,k+[x])or(0,k)
  p=len(k)
  for j in{*k}:a.remove(j)
  if u and len(w)&gt;2:c+=[w]
  if p==m:b+=[w]
  if p&gt;m:m,b=p,[w]
 return b,c

Try it online!
Takes a list of words as input. First convert all words to lowercase, then for each word check all it's rotations and if they are valid, remove them from the list. Outputs two lists containing maximum rotatable words and completely rotatable words respectively.
Needless to say this is not optimal at all and takes several minutes to execute for the provided input.
Output I got for the given dictionary: (['aol', 'alan', 'alar', 'ernst', 'evan', 'hank', 'lesa', 'levi', 'rca', 'terran', 'vera', 'ablest', 'asp', 'ate', 'emit'], ['aol', 'rca', 'asp', 'ate'])
-3 bytes thanks to pxeger