Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- String mode = in.nextLine();
- String s = in.nextLine();
- Map<String, String> map = new HashMap<>();
- map.put("letters", "[a-zA-Z]");
- map.put("numbers", "[0-9]");
- map.put("symbols", "[^a-zA-Z0-9]");
- if(!mode.contains("NONE"))
- for(String x : mode.split(" "))
- s = s.replaceAll(map.get(x),"");
- System.out.println(s);
- System.out.println(asciiValue(s));
- }
- public static int asciiValue(String s)
- {
- int total = 0;
- String taken = "";
- for(char c : s.toCharArray())
- if(taken.indexOf(c) == -1)
- {
- total += c;
- taken += c;
- }
- return total;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement