Matching {x} Repetitions

Sort by

recency

|

99 Discussions

|

  • + 0 comments

    What made this confusing, was that in a previous problem it stated that 0/zero did not count as even. But on this problem 0/zero is counted as even

  • + 0 comments

    Java 15

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    
    public class Solution {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            Pattern pattern = Pattern.compile("^[a-zA-Z02468]{40}[13579\\s]{5}$");
            Matcher matcher = pattern.matcher(scanner.nextLine());
            boolean found = matcher.find();
            System.out.println(found);
        }
    }
    
  • + 0 comments

    JavaScript

    var Regex_Pattern = /^[a-zA-Z02468]{40}[13579\s]{5}$/;
    
  • + 0 comments

    Note: zero counts as an even number.

  • + 0 comments
    Regex_Pattern = r'^[a-zA-Z02468]{40}[\s13579]{5}$'	# Do not delete 'r'.
    
    import re
    
    print(str(bool(re.search(Regex_Pattern, input()))).lower())