anchor.diff:      end.
   
   best_flipped(Solution) ->
  -    FlippedSols = lists:map(fun (I) -> flip_nth(Solution,I) end,
  -              lists:seq(1, length(Solution))),
  +    FlippedSols = lists:map(fun (I) -> flip_nth(Solution, I) end,
  +                            lists:seq(1, length(Solution))),
       First = hd(FlippedSols),
       InitAcc = {First, energy(First)},
       GetBest = fun (S, {AccSol, AccE}) ->
  -        E = energy(S),
  -        case E > AccE of
  -            true -> {S, E};
  -            _ -> {AccSol, AccE}
  -        end
  -    end,
  +                      E = energy(S),
  +                      case E > AccE of
  +                          true -> {S, E};
  +                          _ -> {AccSol, AccE}
  +                      end
  +              end,
       lists:foldl(GetBest, InitAcc, FlippedSols).
   
   flip_nth(Sol, N) ->
  
positive.code: foldzip([], _, Acc) -> Acc;
  foldzip(_, [], Acc) -> Acc;
  foldzip([HA|TA], [HB|TB], Acc) ->
      foldzip(TA, TB, Acc + dot(HA,HB)).
  
  dot(X, X) -> 1;
  dot(_, _) -> -1.
  
negative.code: %% @doc Generates a random solution.
  -spec solution(sim_params()) -> solution().
  solution(SP) ->
      [random:uniform(2)-1 || _ <- lists:seq(1, SP#sim_params.problem_size)].
  
  
  %% @doc Evaluates a given solution. Higher is better.
  