public static ArrayList<Dwarf> split(ArrayList<Dwarf> dwarfs) {
        ArrayList<Dwarf> tempDwarfs = new ArrayList<Dwarf>();
        for (int i = 0; i < dwarfs.size()-1; i+=2) {
            boolean firstDwarf=dwarfs.get(i+1).isHeGood(dwarfs.get(i));
            boolean secondDwarf=dwarfs.get(i).isHeGood(dwarfs.get(i+1));
            
            if (firstDwarf && secondDwarf) {
                tempDwarfs.add(dwarfs.get(i));
                tempDwarfs.add(dwarfs.get(i + 1));
            }
        }

        // odd case
        if (dwarfs.size() % 2 != 0) {
            boolean firstDwarf=dwarfs.get(dwarfs.size()-1).isHeGood(dwarfs.get(0));
            boolean secondDwarf=dwarfs.get(0).isHeGood(dwarfs.get(dwarfs.size()-1));
            
            if (firstDwarf&&secondDwarf) {
                if (!tempDwarfs.contains(dwarfs.get(0))) {
                    tempDwarfs.add(dwarfs.get(0));  
                }
                if (!tempDwarfs.contains(dwarfs.get(dwarfs.size() - 1))) {
                    tempDwarfs.add(dwarfs.get(dwarfs.size() - 1));  
                }
                
            }
            else {
                tempDwarfs.remove(dwarfs.get(dwarfs.size()-1));
                tempDwarfs.remove(dwarfs.get(0));
            } 
          
        }
        return tempDwarfs;
    }