Skip to content

Instantly share code, notes, and snippets.

@lowasser
Last active August 29, 2015 14:15
Show Gist options
  • Save lowasser/e1b57e1a9358cbf52cc6 to your computer and use it in GitHub Desktop.
Save lowasser/e1b57e1a9358cbf52cc6 to your computer and use it in GitHub Desktop.
class Test {
public static void main(String[] args) {
List<Integer> voterA = Arrays.asList(1,2,3,4,5);
List<Integer> voterB = Arrays.asList(1,2,3,4,5);
List<List<Integer>> votes = Arrays.asList(voterA, voterB);
System.out.println(
IntStream.range(0, votes.stream().mapToInt(List::size).max().getAsInt())
.mapToInt(i -> votes.stream().mapToInt(voter -> voter.get(i)).sum())
.collect(Collectors.toList()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment