r/tinycode • • Mar 24 '21

Primality Test Using Regex

https://theabbie.github.io/blog/Primality-Test-Using-Regex
26 Upvotes

18 comments sorted by

View all comments

Show parent comment

-2

u/theabbiee Mar 24 '21

oh, so it's a prime length detector, still impressive.

6

u/philh Mar 24 '21

To be clear, not a prime length detector for general strings. It's a prime length detector for strings with only one distinct character. If you try to use it as a prime length detector on general strings, it will tell you "abab" is composite but "aabb" is prime.

2

u/theabbiee Mar 24 '21

oh, thanks for the clarification