Elixir Cyclic Rotation
defmodule CyclicRotation do
def cyclic_rotation([], _k), do: []
def cyclic_rotation(a, k) do
size = length(a)
shift = rem(k, size)
{front, back} = Enum.split(a, size - shift)
back ++ front
end
end
This rotates the array to the right by K steps and keeps the wrap-around values in the correct order.