Created
June 1, 2017 20:13
-
-
Save danielborowski/ef1edd86045e63006331966151b7ac14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String QuestionsMarks(String str) { | |
str = str.replaceAll("[a-z]+",""); | |
Pattern pattern = Pattern.compile("([0-9])([?])([?])([?])([0-9])"); | |
Pattern pattern01 = Pattern.compile("([0-9])([?])([?])([0-9])"); | |
Matcher matcher01 = pattern01.matcher(str); | |
Pattern pattern02 = Pattern.compile("([0-9])([?])([0-9])"); | |
Matcher matcher02 = pattern02.matcher(str); | |
Matcher matcher = pattern.matcher(str); | |
if (matcher01.find() || matcher02.find()) { | |
return "false"; | |
} else if (matcher.find()) { | |
return "true"; | |
} | |
return "false"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this really pass the examples? Where's the check that the numbers add up to 10? Wouldn't this fail on any numbers not separated by 3 question marks?
I hacked this together in like 5-10 mins. I noticed that Coderbyte doesn't support Perl :(.