Last active
December 19, 2015 04:43
-
-
Save blizzarddreams/978840d89c572e0c0a95 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import java.util.*; | |
| import java.util.stream.Collectors; | |
| /** | |
| * Created by Anthony on 12/18/2015. | |
| */ | |
| public class Solution { | |
| public static void main(String[] args) { | |
| List<String> numbers = new ArrayList<String>(); | |
| numbers.add("1111"); | |
| numbers.add("22-22"); | |
| numbers.add("33 33"); | |
| List<Integer> numbersMapped = numbers.stream().map(i -> Arrays.asList(i.replaceAll(" ", "").replaceAll("-", "").split("")).stream().map(j -> Integer.parseInt(j)).reduce((x, y) -> x+y).get()).collect(Collectors.toList()); | |
| System.out.println(numbersMapped); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment