Learn R Programming

cayleyR (version 0.1.0)

get_reachable_states_light: Find Cycle Length (Lightweight Version)

Description

Fast version of cycle detection that only returns cycle length and unique state count without storing all intermediate states. Useful for testing many operation sequences efficiently.

Usage

get_reachable_states_light(start_state, allowed_positions, k)

Value

List containing:

total_moves

Total number of moves to return to start state

unique_states_count

Number of unique states in the cycle

Arguments

start_state

Integer vector, the initial permutation state

allowed_positions

Character vector, sequence of operations to repeat

k

Integer, parameter for reverse operations

Examples

Run this code
# Quick cycle length check
result <- get_reachable_states_light(1:20, c("L", "X", "L"), k = 4)
cat("Cycle length:", result$total_moves, "\n")
cat("Unique states:", result$unique_states_count, "\n")

# Compare multiple sequences
seq1 <- get_reachable_states_light(1:20, c("1", "3"), k = 4)
seq2 <- get_reachable_states_light(1:20, c("2", "3"), k = 4)
cat("Sequence 1 cycle:", seq1$total_moves, "\n")
cat("Sequence 2 cycle:", seq2$total_moves, "\n")

Run the code above in your browser using DataLab