Hacker News new | past | comments | ask | show | jobs | submit login

(.+|)foo(.+|)

Lol so awesome this. I oblige. Much love!




Powers:

    ^((((((((((x)\10?)\9?)\8?)\7?)\6?)\5?)\4?)\3?)\2?)\1?$
I feel like there's gotta be a sneakier way of doing this.


Completely not sneaky at all, but does reasonably well at 71 points:

  ^(x|xx|xxxx|x{8}|x{16}|x{32}|(x{64})+)$


Mine is a bit shorter, though a bit more "meh" as well.

    ^x{32}$|^(x{2}){1,8}$|^(x{64})+$|^x$


improved, gives 80

    ^(x|(xx){1,9}|x{32}|(x{64})+)$


I tried to get rid of those redundant ^ and $ but it somehow didn't work. I probably forgot to put it all inside one group.


They are not redundant. Any string of one or more exes is going to constrain a substring of exes of length 2^n (consider n=0 for a trivial proof), so you do need those anchors!


I meant my previous post where I had them in every single possibility.


I did similarly, but managed to squeeze out a few more points:

^(((((((((xx?)\9?)\8?)\7?)\6?)\5?)\4?)\3?)\2?)\1?$

(60 points)


A non-cheating solution, 79 points.

  ^((xx?|xxxx)(\2{7})?)(\1{63})?$


I was working on this pattern:

^(x{1,2}){1,2}$

But it wedged my browser as I started adding more terms. :/


58 points:

    ^x$|^(x+)\1$




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: