(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 11.1' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 15797, 526] NotebookOptionsPosition[ 12473, 435] NotebookOutlinePosition[ 12828, 451] CellTagsIndexPosition[ 12785, 448] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Barker Code", "Title",ExpressionUUID->"74177256-8b74-4f1f-8edd-c261adf5504c"], Cell[CellGroupData[{ Cell["Author", "Subsection",ExpressionUUID->"e0c02937-67b1-4bc5-af6f-d4867dc23f2d"], Cell["\<\ Eric W. Weisstein January 30, 2004\ \>", "Text",ExpressionUUID->"090fe02c-de23-4347-8e95-a9ddd4b909c0"], Cell[TextData[{ "This notebook downloaded from ", ButtonBox["http://mathworld.wolfram.com/notebooks/CodingTheory/BarkerCode.nb", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://mathworld.wolfram.com/notebooks/CodingTheory/BarkerCode.nb"], None}], "." }], "Text",ExpressionUUID->"111d985c-b78b-4032-a732-3093169c1c21"], Cell[TextData[{ "For more information, see Eric's ", StyleBox["MathWorld", FontSlant->"Italic"], " entry ", ButtonBox["http://mathworld.wolfram.com/BarkerCode.html", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://mathworld.wolfram.com/BarkerCode.html"], None}], "." }], "Text",ExpressionUUID->"f237f527-c798-4307-9243-430717ff1946"], Cell["\<\ \[Copyright]2005 Wolfram Research, Inc. except for portions noted otherwise\ \>", "Text",ExpressionUUID->"60f5d2d2-1a12-4f96-a99a-0e005165cecf"] }, Open ]], Cell[CellGroupData[{ Cell["Code", "Subsection",ExpressionUUID->"f0be8bef-ec23-4c84-ae0a-fe83111c0bd8"], Cell[BoxData[{ RowBox[{ RowBox[{"BarkerCodeQ", "[", RowBox[{"{", RowBox[{"a1_", ",", "a2_"}], "}"}], "]"}], ":=", RowBox[{ RowBox[{"Abs", "[", RowBox[{"a1", " ", "a2"}], "]"}], "\[LessEqual]", "1"}]}], "\n", RowBox[{ RowBox[{"BarkerCodeQ", "[", "a_List", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"n", "=", RowBox[{"Length", "[", "a", "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"#", "\[LessEqual]", "1"}], "&"}], "/@", RowBox[{"(", RowBox[{"And", "@@", RowBox[{"Abs", "[", RowBox[{"Plus", "@@@", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"a", "[", RowBox[{"[", "i", "]"}], "]"}], RowBox[{"a", "[", RowBox[{"[", RowBox[{"i", "+", "k"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"n", "-", "k"}]}], "}"}]}], "]"}]}], "]"}]}], ")"}]}]}], "\[IndentingNewLine]", "]"}]}]}], "Input",ExpressionUUID->"e26f8946-6ff2-\ 47ad-a957-b76d18edd67c"], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"a", "=", RowBox[{"{", RowBox[{"a1", ",", "a2"}], "}"}]}], ";"}], "\n", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"n", "=", "2"}], "}"}], ",", RowBox[{"Abs", "[", RowBox[{"Plus", "@@@", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"a", "[", RowBox[{"[", "i", "]"}], "]"}], RowBox[{"a", "[", RowBox[{"[", RowBox[{"i", "+", "k"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"n", "-", "k"}]}], "}"}]}], "]"}]}], "]"}]}], "]"}]}], "Input",ExpressionUUID->"fc5d75a7-7005-4c63-a83f-97351a771397"], Cell[BoxData[ RowBox[{"{", RowBox[{"Abs", "[", RowBox[{"a1", " ", "a2"}], "]"}], "}"}]], "Output",ExpressionUUID->\ "46b47263-863d-44f2-b92c-f4593d697b9b"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"Candidates", "[", "n_", "]"}], ":=", RowBox[{"-", RowBox[{"Union", "[", RowBox[{ RowBox[{ RowBox[{"First", "[", RowBox[{"Sort", "[", RowBox[{"{", RowBox[{"#", ",", RowBox[{"Reverse", "[", "#", "]"}], ",", RowBox[{"-", "#"}], ",", RowBox[{"-", RowBox[{"Reverse", "[", "#", "]"}]}]}], "}"}], "]"}], "]"}], "&"}], "/@", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"Outer", "[", RowBox[{"List", ",", RowBox[{"Sequence", "@@", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", "n", "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"n", "-", "1"}]}], "]"}]}], "]"}]}]}]], "Input",ExpressionUUID-\ >"46c124a8-b0ae-401d-9ff6-8c8073bdc963"] }, Open ]], Cell[CellGroupData[{ Cell["Enumeration", "Section",ExpressionUUID->"55329eea-6534-4475-8952-9b84ce69927a"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Candidates", "[", "4", "]"}]], "Input",ExpressionUUID->"dac64c63-966b-4012-87fe-559b4660206f"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", "1"}], "}"}]}], "}"}]], "Output",ExpressionUUID-\ >"6094717c-fca3-489a-8475-4e4f8c149327"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Length", "/@", RowBox[{"Candidates", "/@", RowBox[{"Range", "[", RowBox[{"2", ",", "12"}], "]"}]}]}]], "Input",ExpressionUUID->"1f4fe809-\ 9a36-4dd3-b204-04f0092807aa"], Cell[BoxData[ RowBox[{"{", RowBox[{ "2", ",", "3", ",", "6", ",", "10", ",", "20", ",", "36", ",", "72", ",", "136", ",", "272", ",", "528", ",", "1056"}], "}"}]], "Output",ExpressionUU\ ID->"be7d71fd-21a4-4d07-86af-36e6554255ee"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"2", "^", RowBox[{"(", RowBox[{"n", "-", "2"}], ")"}]}], "+", RowBox[{"2", "^", RowBox[{"(", RowBox[{ RowBox[{"Floor", "[", RowBox[{"n", "/", "2"}], "]"}], "-", "1"}], ")"}]}]}], ",", RowBox[{"{", RowBox[{"n", ",", "12"}], "}"}]}], "]"}]], "Input",ExpressionUUID->\ "68522897-65a6-498a-ad9d-5f6745f10d4c"], Cell[BoxData[ RowBox[{"{", RowBox[{ "1", ",", "2", ",", "3", ",", "6", ",", "10", ",", "20", ",", "36", ",", "72", ",", "136", ",", "272", ",", "528", ",", "1056"}], "}"}]], "Output",E\ xpressionUUID->"cd1adb5e-a814-46be-8acc-40feabc39bba"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Refine", "[", RowBox[{ RowBox[{ RowBox[{"2", "^", RowBox[{"(", RowBox[{"n", "-", "2"}], ")"}]}], "+", RowBox[{"2", "^", RowBox[{"(", RowBox[{ RowBox[{"Floor", "[", RowBox[{"n", "/", "2"}], "]"}], "-", "1"}], ")"}]}]}], ",", RowBox[{ RowBox[{"Mod", "[", RowBox[{"n", ",", "2"}], "]"}], "\[Equal]", "0"}]}], "]"}]], "Input",Expr\ essionUUID->"425973bb-3cff-4242-9908-fe3fd8b75270"], Cell[BoxData[ RowBox[{ SuperscriptBox["2", RowBox[{ RowBox[{"-", "1"}], "+", FractionBox["n", "2"]}]], "+", SuperscriptBox["2", RowBox[{ RowBox[{"-", "2"}], "+", "n"}]]}]], "Output",ExpressionUUID->"15455986-\ 11bd-4854-ae6b-6d41e1b94dae"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"Refine", "[", RowBox[{ RowBox[{ RowBox[{"2", "^", RowBox[{"(", RowBox[{"n", "-", "2"}], ")"}]}], "+", RowBox[{"2", "^", RowBox[{"(", RowBox[{ RowBox[{"Floor", "[", RowBox[{"n", "/", "2"}], "]"}], "-", "1"}], ")"}]}]}], ",", RowBox[{ RowBox[{"Mod", "[", RowBox[{"n", ",", "2"}], "]"}], "\[Equal]", "1"}]}], "]"}], "//", "FullSimplify"}]], "Input",ExpressionUUID->"dc58e45c-5fa3-458c-a903-\ b60f44b1b642"], Cell[BoxData[ RowBox[{ SuperscriptBox["2", RowBox[{ FractionBox["1", "2"], " ", RowBox[{"(", RowBox[{ RowBox[{"-", "3"}], "+", "n"}], ")"}]}]], "+", SuperscriptBox["2", RowBox[{ RowBox[{"-", "2"}], "+", "n"}]]}]], "Output",ExpressionUUID->"9fb6b8ec-\ 402d-4648-8ca7-b01437167026"] }, Open ]], Cell["A005418 ", "Text",ExpressionUUID->"d77be062-70ea-48eb-930f-73c429723483"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"Length", "/@", RowBox[{"(", RowBox[{"l", "=", RowBox[{ RowBox[{ RowBox[{"Select", "[", RowBox[{"#", ",", "BarkerCodeQ"}], "]"}], "&"}], "/@", RowBox[{"Candidates", "/@", RowBox[{"Range", "[", RowBox[{"2", ",", "16"}], "]"}]}]}]}], ")"}]}], "//", "Timing"}]], "Input",ExpressionUUID->"49d28c30-e5d0-4a9f-ac36-10f837bdc09c"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"39.86000000000001`", " ", "Second"}], ",", RowBox[{"{", RowBox[{ "2", ",", "1", ",", "2", ",", "1", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output",ExpressionUUID->"3aa7fc8d-6f14-4993-8dc1-\ 3cee4fd208ff"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ColumnForm", "[", "l", "]"}]], "Input",ExpressionUUID->"cef05b04-4df0-4222-bec9-ce4906cc035b"], Cell[BoxData[ InterpretationBox[GridBox[{ { RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}]}, { RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], "}"}]}, { RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}]}], "}"}]}, { RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1", ",", "1", ",", "1", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}], ",", "1", ",", "1", ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", "}"}]}, { RowBox[{"{", "}"}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], ColumnForm[{{{1, 1}, {1, -1}}, {{1, 1, -1}}, {{1, 1, 1, -1}, {1, 1, -1, 1}}, {{1, 1, 1, -1, 1}}, {}, {{1, 1, 1, -1, -1, 1, -1}}, {}, {}, {}, {{1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1}}, {}, {{1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1}}, {}, {}, {}}], Editable->False]], "Output",ExpressionUUID->"ba4c7c7a-1c59-4dfa-adec-\ 62195f12bc7c"] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{696, 560}, WindowMargins->{{Automatic, 229}, {Automatic, 101}}, FrontEndVersion->"11.1 for Mac OS X x86 (32-bit, 64-bit Kernel) (June 2, \ 2017)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 83, 0, 92, "Title", "ExpressionUUID" -> \ "74177256-8b74-4f1f-8edd-c261adf5504c"], Cell[CellGroupData[{ Cell[688, 26, 83, 0, 44, "Subsection", "ExpressionUUID" -> \ "e0c02937-67b1-4bc5-af6f-d4867dc23f2d"], Cell[774, 28, 113, 3, 49, "Text", "ExpressionUUID" -> \ "090fe02c-de23-4347-8e95-a9ddd4b909c0"], Cell[890, 33, 335, 8, 49, "Text", "ExpressionUUID" -> \ "111d985c-b78b-4032-a732-3093169c1c21"], Cell[1228, 43, 350, 10, 49, "Text", "ExpressionUUID" -> \ "f237f527-c798-4307-9243-430717ff1946"], Cell[1581, 55, 154, 2, 30, "Text", "ExpressionUUID" -> \ "60f5d2d2-1a12-4f96-a99a-0e005165cecf"] }, Open ]], Cell[CellGroupData[{ Cell[1772, 62, 81, 0, 44, "Subsection", "ExpressionUUID" -> \ "f0be8bef-ec23-4c84-ae0a-fe83111c0bd8"], Cell[1856, 64, 1273, 38, 117, "Input", "ExpressionUUID" -> \ "e26f8946-6ff2-47ad-a957-b76d18edd67c"], Cell[CellGroupData[{ Cell[3154, 106, 790, 25, 75, "Input", "ExpressionUUID" -> \ "fc5d75a7-7005-4c63-a83f-97351a771397"], Cell[3947, 133, 163, 4, 32, "Output", "ExpressionUUID" -> \ "46b47263-863d-44f2-b92c-f4593d697b9b"] }, Open ]], Cell[4125, 140, 938, 28, 75, "Input", "ExpressionUUID" -> \ "46c124a8-b0ae-401d-9ff6-8c8073bdc963"] }, Open ]], Cell[CellGroupData[{ Cell[5100, 173, 85, 0, 64, "Section", "ExpressionUUID" -> \ "55329eea-6534-4475-8952-9b84ce69927a"], Cell[CellGroupData[{ Cell[5210, 177, 118, 1, 32, "Input", "ExpressionUUID" -> \ "dac64c63-966b-4012-87fe-559b4660206f"], Cell[5331, 180, 752, 23, 54, "Output", "ExpressionUUID" -> \ "6094717c-fca3-489a-8475-4e4f8c149327"] }, Open ]], Cell[CellGroupData[{ Cell[6120, 208, 204, 5, 32, "Input", "ExpressionUUID" -> \ "1f4fe809-9a36-4dd3-b204-04f0092807aa"], Cell[6327, 215, 240, 5, 32, "Output", "ExpressionUUID" -> \ "be7d71fd-21a4-4d07-86af-36e6554255ee"] }, Open ]], Cell[CellGroupData[{ Cell[6604, 225, 434, 14, 32, "Input", "ExpressionUUID" -> \ "68522897-65a6-498a-ad9d-5f6745f10d4c"], Cell[7041, 241, 250, 5, 32, "Output", "ExpressionUUID" -> \ "cd1adb5e-a814-46be-8acc-40feabc39bba"] }, Open ]], Cell[CellGroupData[{ Cell[7328, 251, 474, 15, 32, "Input", "ExpressionUUID" -> \ "425973bb-3cff-4242-9908-fe3fd8b75270"], Cell[7805, 268, 266, 9, 38, "Output", "ExpressionUUID" -> \ "15455986-11bd-4854-ae6b-6d41e1b94dae"] }, Open ]], Cell[CellGroupData[{ Cell[8108, 282, 525, 17, 32, "Input", "ExpressionUUID" -> \ "dc58e45c-5fa3-458c-a903-b60f44b1b642"], Cell[8636, 301, 319, 11, 39, "Output", "ExpressionUUID" -> \ "9fb6b8ec-402d-4648-8ca7-b01437167026"] }, Open ]], Cell[8970, 315, 79, 0, 30, "Text", "ExpressionUUID" -> \ "d77be062-70ea-48eb-930f-73c429723483"], Cell[CellGroupData[{ Cell[9074, 319, 421, 12, 54, "Input", "ExpressionUUID" -> \ "49d28c30-e5d0-4a9f-ac36-10f837bdc09c"], Cell[9498, 333, 371, 9, 32, "Output", "ExpressionUUID" -> \ "3aa7fc8d-6f14-4993-8dc1-3cee4fd208ff"] }, Open ]], Cell[CellGroupData[{ Cell[9906, 347, 118, 1, 32, "Input", "ExpressionUUID" -> \ "cef05b04-4df0-4222-bec9-ce4906cc035b"], Cell[10027, 350, 2406, 80, 285, "Output", "ExpressionUUID" -> \ "ba4c7c7a-1c59-4dfa-adec-62195f12bc7c"] }, Open ]] }, Open ]] }, Open ]] } ] *)