(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



$RecursionLimit=\[Infinity];
Clear[f];
f[{_}]=0;
f[{n_,_}] := n;
f[{1,0,n_}] := n+1;
f[{1,a_,b_}] := 1+3a+b;
f[{n_,0,0}] := 2^(n+1)+n-2;
f[{0, s___}] := f[{s}];
f[s_List]:= f[s] = Max[
Max[Table[If[s[[i]]==0,0,
ns=s; ns[[i]]-=1; ns[[i+1]]+=2; f[ns]+1
], {i, Length[s]-1}]],
Max[Table[If[s[[i]]==0,0,
ns=s; ns[[i]]-=1; {ns[[i+1]], ns[[i+2]]}={ns[[i+2]], ns[[i+1]]}; f[ns]+1
], {i, Length[s]-2}]]
];
f[s___] := f[{s}]



