Last active
August 29, 2015 14:15
-
-
Save lowasser/e1b57e1a9358cbf52cc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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