package utils; import model.Room; import model.template.Template; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author duh * @create 2018/7/25 14:53 * @email duh@elab-plus.com **/ public class CalcYizhiArrayUtils { private List roomLength; private List oneAlignAllLength; private List twoAlignAllShortLength; private List twoAlignAllLongLength; public void calcYizhiWithOnlyOneTwoAlign(){ int totalOneLenth = 0; for(int length : oneAlignAllLength){ totalOneLenth += length; } int leftForTwo = roomLength.get(3) - totalOneLenth; if(leftForTwo>0){ System.out.println("可以一字排,方案如下:"); } } /** * 获取n个数的所有组合 * @param n */ public List> getAllArrayList(int n){ List> arrayList = new ArrayList<>(); if(n < 1){ return arrayList; }else if(n==1){ List list = new ArrayList<>(); list.add(n); arrayList.add(list); return arrayList; } arrayList = getAllArrayList(n-1); for(int index = arrayList.size() -1;index>=0;index--){ List list = arrayList.remove(index); for(int i = 0;i newList = new ArrayList<>(); newList.addAll(list); newList.add(i,n); arrayList.add(newList); } } return arrayList; } /** * 排列数 * @param n * @return */ public int A(int n){ if(n <= 0){ return 0; }else if(n==1){ return 1; }else { return n*A(n-1); } } }