Quantcast
Channel: Match strings whose length is a fourth power - Code Golf Stack Exchange
Browsing latest articles
Browse All 8 View Live

Answer by Deadcode for Match strings whose length is a fourth power

.NET, 39 37 bytes^(?=((?>^((?<-1>x)+|x)|\1\2\2))*$){2}Try it online!Not only does this outgolf primo's amazing answer, but it runs at very close to exactly the same speed under .NET's regex...

View Article


Answer by Deadcode for Match strings whose length is a fourth power

ECMAScript, 41 bytes^((?=(x(x*)|)(?=(\2*)\3+$)(\2*$\4))\5){2}Try it online! - ECMAScript (SpiderMonkey)Try it online! - ECMAScript (Node.js - faster)Try it online! - .NET, in ECMAScript emulation...

View Article


Answer by Deadcode for Match strings whose length is a fourth power

Perl / Java / PCRE / .NET, 35 bytes((\2x|^x)+)\1(\3xx|x(?=\2$))+$|^x?$This beats primo's solution by 4 bytes while supporting the exact same set of regex engines.Try it online! - PerlTry it online! -...

View Article

Answer by primo for Match strings whose length is a fourth power

Perl / Java / PCRE / .NET, 39 bytesAnother SolutionThis is, in my opinion, one of the most interesting problems on the site. I need to thank deadcode for bumping it back up to the...

View Article

Answer by Deadcode for Match strings whose length is a fourth power

ECMAScript / Perl / Java / Python / Ruby / PCRE / .NET, 50 bytesHere is a solution that does not use conditionals, forward-declared or nested backreferences, lookbehind, balancing groups, or regex...

View Article


Image may be NSFW.
Clik here to view.

Answer by n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ for Match strings whose length is a...

Perl / Java / PCRE / .NET, 53 bytesSolution^((?=(^|(?<=^x)x|xx\2))(?=(^|\2\3))(^x|\4\3{12}xx))*$This regex is compatible with Java, Perl, PCRE and .NET flavors. This regex uses quite a range of...

View Article

Answer by Volatility for Match strings whose length is a fourth power

Perl / PCRE / .NET, 66 bytesThis (ir)regular expression seems to work.^((?(1)((?(2)\2((?(3)\3((?(4)\4x{24}|x{60}))|x{50}))|x{15}))|x))*$This regex is compatible with PCRE, Perl, .NET flavors.This...

View Article

Match strings whose length is a fourth power

Within the scope of this question, let us consider only strings which consist of the character x repeated arbitrary number of times.For example:<empty>xxxxxxxxxxxxxxxxxxx(Well, actually it...

View Article

Browsing latest articles
Browse All 8 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>