Advertisement
KristianIvanov00

Emoji_Detector

Jul 29th, 2023
876
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. package FinalExamPrep2907_2;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Scanner;
  6. import java.util.regex.Matcher;
  7. import java.util.regex.Pattern;
  8.  
  9. public class P02_EmojiDetector {
  10.     public static void main(String[] args) {
  11.         Scanner scanner = new Scanner(System.in);
  12.  
  13.         String input = scanner.nextLine();
  14.         String regex = "([:*]{2})(?<emoji>[A-Z][a-z]{2,})\\1";
  15.  
  16.         Pattern pattern = Pattern.compile(regex);
  17.         Matcher matcher = pattern.matcher(input);
  18.  
  19.         List<String> coolEmojisList = new ArrayList<>();
  20.  
  21.         long coolThreshold = 1;
  22.         for (int i = 0; i < input.length(); i++) {
  23.             char currentCh = input.charAt(i);
  24.             if (Character.isDigit(currentCh)) {
  25.                 int currentDigit = Integer.parseInt(currentCh + "");
  26.                 coolThreshold *= currentDigit;
  27.             }
  28.         }
  29.  
  30.         int countEmojis = 0;
  31.         while (matcher.find()) {
  32.             countEmojis++;
  33.             String delimiter = matcher.group(1);
  34.             String emojiWord = matcher.group("emoji");
  35.             int currentEmojiCoolness = 0;
  36.             for (int i = 0; i < emojiWord.length(); i++) {
  37.                 char currentCh = emojiWord.charAt(i);
  38.                 currentEmojiCoolness += (int)(currentCh);
  39.             }
  40.  
  41.             if (currentEmojiCoolness > coolThreshold) {
  42.                 coolEmojisList.add(delimiter + emojiWord + delimiter);
  43.             }
  44.         }
  45.  
  46.         System.out.println("Cool threshold: " + coolThreshold);
  47.         System.out.printf("%d emojis found in the text. The cool ones are:%n", countEmojis);
  48.         for (String e : coolEmojisList) {
  49.             System.out.println(e);
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Comments
  • prashant0695
    323 days
    # text 2.29 KB | 0 0
    1. wsa030:rtestuser 8] cli version
    2. Current Version
    3. ===============
    4. Product: Cisco S600V Web Security Virtual Appliance
    5. Model: S600V
    6. Version: 12.0.5-011
    7. Build Date: 2022-05-06
    8. Install Date: 2023-07-29 09:01:01
    9. Serial #: 42294D401307BCB4DBEC-E1431E45EFA5
    10. BIOS: 6.00
    11. CPUs: 12 expected, 12 allocated
    12. Memory: 24576 MB expected, 24576 MB allocated
    13. Hard disk: 750 GB, or 1024 GB, or 1536.0 GB, or 2048 GB, or 2457.6 GB expected; 750 GB allocated
    14. RAID: NA
    15. RAID Status: Unknown
    16. RAID Type: NA
    17. BMC: NA
    18. Cisco DVS Engine: 1.0 (Never Updated)
    19. Cisco DVS Malware User Agent Rules: 0.554 (Never Updated)
    20. Cisco DVS Object Type Rules: 0.554 (Never Updated)
    21. Cisco Trusted Root Certificate Bundle: 2.2 (Sat Jul 29 08:55:15 2023)
    22. Cisco Certificate Blacklist: 1.3 (Sat Jul 29 08:55:15 2023)
    23. How-Tos: 1.0 (Never Updated)
    24. L4 Traffic Monitor Anti-Malware Rules: 1.0 (Never Updated)
    25. Cisco Web Usage Controls - Web Categorization Engine: 1.12.4.944 (Never Updated)
    26. Cisco Web Usage Controls - Dynamic Content Analysis Engine: 2.1.0-016 (Never Updated)
    27. Cisco Web Usage Controls - Dynamic Content Analysis Engine Data: 3.1.0001 (Never Updated)
    28. Cisco Web Usage Controls - Application Visibility and Control Engine: 1.1.0-076 (Never Updated)
    29. Cisco Web Usage Controls - Application Visibility and Control Data: 1.1.0.76-001 (Sat Jul 29 09:07:50 2023)
    30. Web Reputation IP Filters: 1690620950 (Sat Jul 29 11:26:19 2023)
    31. Web Reputation Rules: 1688058196 (Sat Jul 29 11:26:19 2023)
    32. Web Reputation URL Queries Database: 1690620037 (Sat Jul 29 11:26:20 2023)
    33. Talos Intelligence engine: 1.12.4.944 (Never Updated)
    34. Webroot Anti-Malware Engine: 2.1.5.8 (Never Updated)
    35. Webroot Engine Definition: 2.1.5.8 (Never Updated)
    36. Webroot Malware Categories DATs: 1178 (Sat Jul 29 09:07:38 2023)
    37. McAfee Anti-Malware Engine: 6600 (Sat Jul 29 09:24:20 2023)
    38. McAfee Engine Definition: 5200 (Never Updated)
    39. McAfee DATs: 10786 (Sat Jul 29 12:42:04 2023)
    40. Sophos Engine: 3.2.07.387.0_6.01 (Sat Jul 29 09:15:52 2023)
    41. Sophos IDE: 2023072902 (Sat Jul 29 09:15:52 2023)
    42. Advanced Malware Protection - Engine: 1.0 (Never Updated)
    43. Advanced Malware Protection - Engine Definition: 1.0.0-119
    44. Advanced Malware Protection - Pre-class Engine: 1.0.0-118 (Sat Jul 29 09:01:52 2023)
    45. Advanced Malware Protection - Cisco Internal Certificates: 1.0.0-101 (Sat Jul 29 08:54:51 2023)
    46.  
  • prashant0695
    323 days
    Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement