Skip to content

Instantly share code, notes, and snippets.

@blizzarddreams
Last active December 19, 2015 04:43
Show Gist options
  • Select an option

  • Save blizzarddreams/978840d89c572e0c0a95 to your computer and use it in GitHub Desktop.

Select an option

Save blizzarddreams/978840d89c572e0c0a95 to your computer and use it in GitHub Desktop.
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