A Collection of Code Snippets in as Many Programming Languages as Possible

This project is maintained by TheRenegadeCoder

Welcome to the Maximum Array Rotation in Mathematica page! Here, you'll find the source code for this program as well as a description of how the program works.

```
(* Code *)
(* The actual maximum array rotation operating on Mathematica lists: *)
longestArrayRotation = a \[Function] Max @@
Table[
Dot[ (* inner product *)
RotateRight[a, i], (* rotated input list *)
Range[0, Length[a] - 1](* list of weights *)],
{i, Length[a]}];
(* The outer function provides the 'user interface': *)
longestArrayRotationMain = l \[Function]
Module[{e = "Usage: please provide a list of integers (e.g. \"8, 3, 1, 2\")"},
Catch[
longestArrayRotation @@ Map[
(* convert string to integer, or throw *)
s \[Function] If[StringMatchQ[s, DigitCharacter ..],
FromDigits[s],
Throw[e]],
(* construct argument to array rotation *)
{StringSplit[If[StringLength[l] > 0, l, Throw[e]], ", "]},
{-1} (* at each leaf *)]]];
(* Valid Tests *)
Print /@ longestArrayRotationMain /@ {
"3, 1, 2, 8",
"1, 2, 8, 3",
"8, 3, 1, 2"
};
(* Invalid Tests *)
longestArrayRotationMain[""]
```

Maximum Array Rotation in Mathematica was written by:

- Ben Hekster

If you see anything you'd like to change or update, please consider contributing.

No 'How to Implement the Solution' section available. Please consider contributing.

No 'How to Run the Solution' section available. Please consider contributing.