Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class TaskTwo {
- public static void main(String[] args) {
- Scanner scan =new Scanner(System.in);
- String input = scan.nextLine();
- String regex = "(\\#|\\$|\\%|\\*|\\&)(?<nameOfRacer>\\w+)\\1=(?<length>\\d+)!!(?<geohashcode>\\w+){5,}";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(input);
- StringBuilder sb =new StringBuilder();
- if(matcher.find()){
- String geohashcode = matcher.group("geohashcode");
- int length = Integer.parseInt(matcher.group("length"));
- String nameOfRacer = matcher.group("nameOfRacer");
- for (int pos = 0; pos < geohashcode.length(); pos++) {
- char currentSymbol = input.charAt(pos);
- char decrypt = (char) (currentSymbol+length);
- sb.append(decrypt);
- }
- System.out.printf("Coordinates found! %s -> %s",nameOfRacer,sb.toString());
- }else{
- System.out.println("Nothing found!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement