package com.thinker.bishi.offer;

/**
 * @author lzh
 */
public class EqualCount {
    private static int count = 0;
    private static int realResult = 6;

    public static void go(int[] opts,int result,int current,String sym){
        if(current >= opts.length-1) {
            if(result == EqualCount.realResult)
                count += 1;
            return;
        }
        if("+".equals(sym))
            result += opts[current];
        if("-".equals(sym))
            result -= opts[current];
        go(opts, result, current+1, "+");
        go(opts, result, current+1, "-");
    }

    public static void main(String[] args) {
        int opts[] = new int[]{1,2,3,4,5,6,7,8,9};
        go(opts,opts[0],1,"+");
        go(opts,opts[0],1,"-");
        System.out.println(count);
    }
}
