From: http://quaxio.com/triple/
^([0369]|[258][0369]*[147]|[147]([0369]|[147][0369]*[258])*[258]|[258][0369]*[258]([0369]|[147][0369]*[258])*[258]|[147]([0369]|[147][0369]*[258])*[147][0369]*[147]|[258][0369]*[258]([0369]|[147][0369]*[258])*[147][0369]*[147])*$
Re:Regex Golf
by raverbashing on Saturday December 21, 2013 @10:36AM
(#6946874)
The idea is as thus:
Remember division rules? If the sum of digits is divisible by 3, then the number is divisible by 3
So, if you have 0, 3, 6, 9, it's as you can remove them, the value won't change
Remaining are the 2, 3, etc digit numbers divisible by 3
Re:Regex Golf
by moron4hire on Friday December 20, 2013 @11:58AM
(#6942378)
569pts: ([^31]0|31|[017]2|[03]03|[^1]4|(900|01|7)5|6|[48]7|[57]8|09)$
Originally had 568, then saw this and improved. :)
580pts: 00(0$|3|6|9|12|15)|[^0]14|.53|^3[^38]|55|43|23|9.7
Nice. A smidge better at 582:
5[54]|2[437]|00($|[369]|1[25])|^8[17]|^3[29]|9.7One more smidgen, behold 584:
5[54]|2[437]|00($|[369]|1[25])|^[83][1729]|9.7586:
^[378][12479]|00($|[369]|1[25])|5[45]|2[347]589: ^[378][12479]|00($|[369]|1[25])|55|2[347]
I got 187 with this
[369](?![7238])|(?:0)12
It's sloppy and certainly not correct, but a decent score.
Re:Regex Golf
by danielweber on Friday December 20, 2013 @11:09AM
(#6942047)
My guess is that 147 must appear the same number of times as 258, but I'm not sure if that's even expressible in regexp.
Re:Regex Golf
by johnlbevan2 on Friday December 20, 2013 @03:07PM
(#6943632)
Refined:
[0369] can appear any number of times
[147] and [258] must appear an equal number of times, or for any remaining:
[147] must appear a multiple of 3 times
[258] must appear a multiple of 3 times
No. 111 is a multiple of 3.
Re:Regex Golf
by johnlbevan2 on Friday December 20, 2013 @12:56PM
(#6942832)
Sadly that wouldn't work for: 140091876
147 = 4 times
258 = 1 time
Re:Regex Golf
by galen_tyrol on Friday December 20, 2013 @12:12PM
(#6942480)
^[01349][064] works for 197
And conditionals don't seem to work?