SHARE
TWEET

SantasSecretHelper

a guest Mar 24th, 2020 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class SantasSecretHelper {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.  
  9.         Pattern pattern = Pattern.compile("\\@([A-Za-z]+)[^\\@\\-\\!\\:\\>]*\\!([A-Z])\\!");
  10.  
  11.         int n = Integer.parseInt(sc.nextLine());
  12.         String input = sc.nextLine();
  13.  
  14.         while (!input.equals("end")){
  15.             String decrypt = "";
  16.  
  17.             for (int i = 0; i < input.length(); i++){
  18.                 int ascii = (int)input.charAt(i) - n;
  19.                 decrypt += (char)ascii;
  20.             }
  21.  
  22.             Matcher matcher = pattern.matcher(decrypt);
  23.  
  24.             while (matcher.find()){
  25.                 String behevier = matcher.group(2);
  26.  
  27.                 if (behevier.equals("G")){
  28.                     String name = matcher.group(1);
  29.                     System.out.println(name);
  30.                 }
  31.             }
  32.  
  33.             input = sc.nextLine();
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top