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