You are viewing a single comment's thread. Return to all comments →
Elixir solution:
defmodule Solution do def rotate(_, c) when c == 0 do [] end def rotate(s, c) do [start | rest] = String.codepoints(s) r = List.to_string(rest) <> start [r] ++ rotate(r, c - 1) end def rotate_all(_, elements) do Enum.map(elements, fn x -> Solution.rotate(x, String.length(x)) |> Enum.join(" ") end) end end input = IO.read(:stdio, :all) |> String.split("\n") [n | elements] = input Solution.rotate_all(n, elements) |> Enum.join("\n") |> IO.puts
Seems like cookies are disabled on this browser, please enable them to open this website
Rotate String
You are viewing a single comment's thread. Return to all comments →
Elixir solution: