The greedy regex (cops)

6

3

This is the cops' post. The robbers' is here.

You make a program and a regex.

For most inputs, one of the following happens:

  • the regex doesn't match, and the program returns a falsey value
  • the regex doesn't match, and the program returns a truthy value
  • the regex matches, and the program returns a truthy value

But for one (or more) input, the regex matches, but the program returns a falsy value.

You should try to keep this input hidden. Robbers will try to find an input where the regex matches, but the program returns a falsy value.

Post your program and your regex, as well as your language name, byte count of the program, regex flavor, and byte count of the regex.

If a robber finds an input where the regex matches, but the program returns a falsy value, even if it wasn't the intended input your program is considered cracked, and you edit in a link to the robber's crack.

If nobody has cracked your program & regex after a week, then edit in that your submission is safe and is therefore not eligible for cracking. Also edit in the intended input. The shortest (program bytes + regex bytes) non-cracked submission wins.

Example

Let's say your regex is (all of the flavors):

/^[0-9]$/

And your program is (JS):

x=>Boolean(parseInt(x))

Then a valid crack would be 0, because the regex matches 0 but 0 is falsey.

Delimiters don't count in the byte count.

I can't enforce the banning of hash functions with rules, but please don't use SHA/RSA or anything that is unfair to the robbers

programmer5000

Posted 2017-08-29T01:09:31.210

Reputation: 7 828

2Are cryptographic hash functions allowed? I can imagine regex (..)+ and program print hash(input)==... – fireflame241 – 2017-08-29T01:21:06.703

1@fireflame241 see edits – programmer5000 – 2017-08-29T12:39:00.117

Answers

3

Python, cracked

Regex: (?!.)

Program: from operator import not_

This is a little easier than my previous one.

pppery

Posted 2017-08-29T01:09:31.210

Reputation: 3 987

3

JavaScript (Cracked)

Regex: ..
Program: a=>[...a].length-1

This is an easy one.


Intended solution




user72349

Posted 2017-08-29T01:09:31.210

Reputation:

Cracked – Eli Richardson – 2017-08-29T09:19:56.240

1

Python 3, cracked by ovs

Regex: .

Program: lambda a:len(a.lower()) == 1

This shouldn't be wasn't too hard.

pppery

Posted 2017-08-29T01:09:31.210

Reputation: 3 987

Cracked – ovs – 2017-08-29T07:03:19.717

1

JavaScript ES6, 12 bytes + 3 bytes

Regex: ...

Code: a=>a+1<a-1+2

iovoid

Posted 2017-08-29T01:09:31.210

Reputation: 411

2It is supposed to be hard to produce a false. With your program, almost any 3-digits number (and more inputs) would produce it. – Uriel – 2018-02-18T22:47:59.330

0

Java (OpenJDK 9), 198 bytes, (Cracked)

public static boolean isProgramValid(String n) {
    try{
        Class.forName(n);
    } catch(Exception e){
       return false;
    }
    return true;
}

public static String regex = "^(?is)([a-z]+\\.){4}.*$";

Should be an easy one.

Try it online!

Roman Gräf

Posted 2017-08-29T01:09:31.210

Reputation: 2 915

3Isn't the question tagged as code-golf? Why all these white spaces and boolean instead of int? – None – 2017-08-29T12:25:53.973

1Cracked – PunPun1000 – 2017-08-29T12:33:54.157

-3

Pyth

Regex: .*

Program: !qC%.hz^TT"U|(¡

Try it online!

Simple hash function, shouldn't be allowed, but it is. I could've made it much stronger, but I tried to optimize for byte count.

Sebastian

Posted 2017-08-29T01:09:31.210

Reputation: 146

1Stop suggesting we make things into pop-cons! Pop-cons are almost never good nowadays, and this challenge is much much better as a cops and robbers. The issue is that the OP hasn't yet clarified, which does not mean that it should be a pop-con. – caird coinheringaahing – 2017-08-29T11:50:46.057

He has to do one of the two things, otherwise the winner is whoever can create the shortest hash that remains secure. – Sebastian – 2017-08-29T11:58:35.597

1

I'm not arguing with that, I'm arguing with the Maybe make the challenge a popularity contest instead. That is in no way the correct solution to a problem in a question. Take a look through this and see how many are closed. Pop-con is not a solution to an under specified challenge, it is a separate challenge type.

– caird coinheringaahing – 2017-08-29T12:07:34.693

Good point, turns out I wasn't aware of what makes a challenge a good popularity contest. Edited my answer. – Sebastian – 2017-08-29T15:23:36.770