import java.util.ArrayList; import java.util.List; public class TRAII_25_X6_skeleton implements TRAII_25_X6 { // ^^^ own id here /** * SELF-EVALUATION HERE: * * * */ /** * Distribute list of input elements so that the outputBins combined will have all of the inputs elements. * Goal is to have the elements in each outputBin to have as similar sum of elements as possible. * * @param input elements to distribute * @param outputBins result bins (a list of empty lists) * @param maxTime maximum time to use in seconds */ @Override public void partition(ArrayList input, ArrayList> outputBins, int maxTime) { int k = outputBins.size(); // number of output bins int nextBin = 0; // distribute all input elements to bins using round-robin for (int elem : input) { outputBins.get(nextBin).add(elem); nextBin = (nextBin + 1) % k; } } int sum(List bin) { return bin.stream().reduce(0, Integer::sum); } }