package HelloTest;

import java.util.Arrays;

public class TLUTest {

    double[] myArr={1.1,3.1,-1,-2,0.5};

    int threshold=1;

    private void getTuple(int[] arr,int changeIndex){
        if(changeIndex<0){
            System.out.println(Arrays.toString(arr)+"--->"+ getRes(arr));
            return;
        }

        arr[changeIndex]=0;
        getTuple(arr,changeIndex-1);


        arr[changeIndex]=1;
        getTuple(arr,changeIndex-1);

    }


    private int getRes(int[] arr){
        double sum=0;

        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i]*myArr[i];
        }

        if(sum>=threshold){
            return 1;
        }else {
            return 0;
        }
    }

    public static void main(String[] args) {
        TLUTest test=new TLUTest();

        int[] arr=new int[test.myArr.length];

        test.getTuple(arr,arr.length-1);
    }
}

@@ -35,17 +35,68 @@
 il.Array
-s
+List;%0Aimport java.util.Arrays;%0Aimport java.util.List
 ;%0A%0Apubli
@@ -177,16 +177,76 @@
 old=1;%0A%0A
+    ArrayList%3CArrayList%3CInteger%3E%3E list=new ArrayList%3C%3E();%0A%0A%0A
     priv
@@ -335,26 +335,18 @@
    S
-ystem.out.println(
+tring res=
 Arra
@@ -365,456 +365,1588 @@
 arr)
-+%22---%3E%22+ getRes(arr));%0A            return;%0A        %7D%0A%0A        arr%5BchangeIndex%5D=0;%0A        getTuple(arr,changeIndex-1);%0A%0A%0A        arr%5BchangeIndex%5D=1;%0A        getTuple(arr,changeIndex-1);%0A%0A    %7D%0A%0A%0A    private int getRes(int%5B%5D arr)%7B%0A        double sum=0;%0A%0A        for (int i = 0; i %3C arr.length; i++) %7B%0A            sum+=arr%5Bi%5D*myArr%5Bi%5D;%0A        %7D%0A%0A        if(sum%3E=threshold)%7B%0A            return 1;%0A        %7Delse %7B%0A            return 0;%0A        %7D%0A    %7D
+;%0A            res=res.replaceAll(%22%5C%5C%5B%22,%22%22);%0A            res=res.replaceAll(%22%5C%5C%5D%22,%22%22);%0A%0A            int booleanRes=getRes(arr);%0A%0A            res=res+%22, %22+ booleanRes;%0A%0A            if(booleanRes==1)%7B%0A                ArrayList%3CInteger%3E temp=new ArrayList%3C%3E();%0A%0A                for (int i:arr) %7B%0A                    temp.add(i);%0A                %7D%0A%0A                list.add(temp);%0A            %7D%0A%0A            System.out.println(res.replaceAll(%22 %22,%22%22));%0A            return;%0A        %7D%0A%0A        arr%5BchangeIndex%5D=0;%0A        getTuple(arr,changeIndex-1);%0A%0A%0A        arr%5BchangeIndex%5D=1;%0A        getTuple(arr,changeIndex-1);%0A%0A    %7D%0A%0A%0A    private int getRes(int%5B%5D arr)%7B%0A        double sum=0;%0A%0A        for (int i = 0; i %3C arr.length; i++) %7B%0A            sum+=arr%5Bi%5D*myArr%5Bi%5D;%0A        %7D%0A%0A        if(sum%3E=threshold)%7B%0A            return 1;%0A        %7Delse %7B%0A            return 0;%0A        %7D%0A    %7D%0A%0A    private String getLatex()%7B%0A        StringBuilder stringBuilder=new StringBuilder(%22f(a,b,c,d,e)=%22);%0A%0A        for (int i = 0; i %3Clist.size() ; i++) %7B%0A            ArrayList%3CInteger%3E arr=list.get(i);%0A%0A            for (int j = 0; j %3Carr.size() ; j++) %7B%0A                char c= (char) ('a'+j);%0A%0A                int res=arr.get(j);%0A%0A                if(res==0)%7B%0A                    //qu fan%0A                    stringBuilder.append(%22 %5C%5Cbar%7B%22+c+%22%7D%22);%0A                %7Delse%7B%0A                    stringBuilder.append(%22 %22+c);%0A                %7D%0A            %7D%0A%0A%0A            if(i!=list.size()-1)%7B%0A                stringBuilder.append(%22+%22);%0A            %7D%0A        %7D%0A%0A        return stringBuilder.toString();%0A    %7D%0A%0A%0A%0A%0A%0A
 %0A%0A  
@@ -2112,16 +2112,137 @@
 ngth-1);
+%0A%0A        System.out.println(%22=======Here is the boolean function:=======%22);%0A        System.out.println(test.getLatex());
 %0A    %7D%0A%7D

add TLUtest for Problem2