5 added 438 characters in body
source | link

Python 3, 269 254 252252 246 bytes

  
d,m,i=eval(input())
def fS=set()
for n in range(1,T=1001):
 T=X=()
 while len(T)**3<1e9>=n:
 x=[n T=(n,)+T;n=[n//d,n*m+i][n%d>0];I=T.indexn*m+i][n%d>0]
  if xn in T:L=T[I=T.index;L=T[:I(xn)+1];M=I(min(L));return L[M;X=L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)S|={X}
for x in sorted(set(map(f,range(1,1001)))S):print(x and"LOOP"or"DIVERGENT",*x[::-1])

(Now 10 times slower to save a few bytes. Typical code golf.)

Input a list via STDIN (e.g. [2, 3, 1]). There'sI'm thinking that there's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or Loops are represented by nonempty tuples, in the case ofbut more importantly divergence, is represented by an emptyempty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Previous submission, 252 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0];I=T.index
 if x in T:L=T[:I(x)+1];M=I(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

This one's a lot faster.

Python 3, 269 254 252 bytes

 
d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0];I=T.index
 if x in T:L=T[:I(x)+1];M=I(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Python 3, 269 254 252 246 bytes

 
d,m,i=eval(input())
S=set()
for n in range(1,1001):
 T=X=()
 while len(T)**3<1e9>=n:
  T=(n,)+T;n=[n//d,n*m+i][n%d>0]
  if n in T:I=T.index;L=T[:I(n)+1];M=I(min(L));X=L[M:]+L[:M]
 S|={X}
for x in sorted(S):print(x and"LOOP"or"DIVERGENT",*x[::-1])

(Now 10 times slower to save a few bytes. Typical code golf.)

Input a list via STDIN (e.g. [2, 3, 1]). I'm thinking that there's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers and take only the unique outputs. However, there are two little tricks in there:

  • Loops are represented by nonempty tuples, but more importantly divergence is represented by an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Previous submission, 252 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0];I=T.index
 if x in T:L=T[:I(x)+1];M=I(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

This one's a lot faster.

4 added 9 characters in body
source | link

Python 3, 269 254254 252 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0]n*m+i][n%d>0];I=T.index
 if x in T:L=T[:T.indexI(x)+1];M=L.index+1];M=I(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Python 3, 269 254 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0]
 if x in T:L=T[:T.index(x)+1];M=L.index(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Python 3, 269 254 252 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0];I=T.index
 if x in T:L=T[:I(x)+1];M=I(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.
3 added 110 characters in body
source | link

Python 3, 269 258254 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0]
 if x in T:L=T[:T.index(x)+1];M=L.index(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
M=sortedfor x in sorted(set(map(f,range(1,1001))))
for x in M:print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Python 3, 269 258 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0]
 if x in T:L=T[:T.index(x)+1];M=L.index(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
M=sorted(set(map(f,range(1,1001))))
for x in M:print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.

Python 3, 269 254 bytes

d,m,i=eval(input())
def f(n,T=()):
 x=[n//d,n*m+i][n%d>0]
 if x in T:L=T[:T.index(x)+1];M=L.index(min(L));return L[M:]+L[:M]
 return()if(T[1000:]or x>1e9)else f(x,(x,)+T)
for x in sorted(set(map(f,range(1,1001)))):print(x and"LOOP"or"DIVERGENT",*x[::-1])

Input a list via STDIN (e.g. [2, 3, 1]). There's got to be a better way of standardising the cycles...

The approach is quite straightforward — test all 1000 numbers (using the function f), and take only the unique outputs. However, there are two little tricks in there:

  • f either returns the loop as a non-empty tuple (truthy) or, in the case of divergence, an empty tuple. This is good because:

    • It doesn't break sorted, and will even appear before all the loop tuples
    • It allows us to select a string via x and"LOOP"or"DIVERGENT"
    • *()[::-1] doesn't affect print
  • The loops are built backwards to turn "sort ascending by last element" into "sort ascending by first element", which removes the need to pass a lambda into sorted.
2 added 110 characters in body
source | link
1
source | link