Remote-Url: https://codegolf.stackexchange.com/questions/3503/hard-code-golf-regex-for-divisibility-by-7/3505 Retrieved-at: 2022-01-29 16:27:35.359987+00:00 Stack Exchange Network Stack Exchange network consists of 178 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange [ ] Loading… 1. 2. 0 3. +0 4. □ Tour Start here for a quick overview of the site □ Help Center Detailed answers to any questions you might have □ Meta Discuss the workings and policies of this site □ About Us Learn more about Stack Overflow the company □ Business Learn more about hiring developers or posting ads with us 5. 6. Log in Sign up 7. current community □ Code Golf help chat □ Code Golf Meta your communities Sign up or log in to customize your list. more stack exchange communities company blog Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up. Sign up to join this community [ano] Anybody can ask a question [ano] Anybody can answer [an] The best answers are voted up and rise to the top Code Golf 1. Home 2. 1. Public 2. Questions 3. Tags 4. Users 5. Unanswered 6. Find a Job 7. Jobs 8. Companies 3. Teams Stack Overflow for Teams – Collaborate and share knowledge with a private group. [teams-illo-free-si] Create a free Team What is Teams? 1. Teams 2. Create free Team Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Learn more Hard code golf: Regex for divisibility by 7 Ask Question Asked 10 years, 5 months ago Active 1 month ago Viewed 37k times 81 29 \$\begingroup\$ Matthias Goergens has a 25,604-character (down from the original 63,993-character) regex to match numbers divisible by 7, but that includes a lot of fluff: redundant parentheses, distribution (xx|xy|yx|yy rather than [xy] {2}) and other issues, though I'm sure a fresh start would be helpful in saving space. How small can this be made? Any reasonable variety of regular expressions are allowed, but no executable code in the regex. The regular expression should match all strings containing the decimal representation of a number divisible by 7 and no others. Extra credit for a regex that does not allow initial 0s. code-golf math regular-expression Share Improve this question Follow edited Nov 9 '15 at 14:23 Charles asked Aug 19 '11 at 20:21 [deb] CharlesCharles 2,55311 gold badge1414 silver badges2222 bronze badges \$\endgroup\$ 7 • \$\begingroup\$ What is the precise intention? Does it have to match all numbers of any size divisible by 7, or, for example, only valid 32-bit uints? \$\endgroup\$ – Peter Taylor Aug 19 '11 at 20:38 • 2 \$\begingroup\$ @Peter Taylor: It should match all strings that are the decimal representation of a number divisible by 7. Extra credit for solutions that disallow leading 0s. \$\endgroup\$ – Charles Aug 19 '11 at 22:13 • 1 \$\begingroup\$ By any chance... need the regex not match numbers indivisible by 7? \$\endgroup\$ – boothby Jan 7 '14 at 8:25 • \$\begingroup\$ @boothby: Absolutely, else you could just use the empty expression. \$\endgroup\$ – Charles Jan 7 '14 at 9:12 • 2 \$\begingroup\$ @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Yes, 0 should be allowed in either version. \$\ endgroup\$ – Charles Mar 16 '16 at 5:28 | Show 2 more comments 6 Answers 6 Active Oldest Votes 102 \$\begingroup\$ [S:13,755:S] [S:12,699:S] 12,731 Characters This regex does not reject leading zero. (0|7|[18]5*4|(2|9|[18]5*6)(3|[29]5*6)*(1|8|[29]5*4)|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))|(4|[18]5*[18]|(2|9|[18]5*6)(3|[29]5*6)*(5|[29]5*[18])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(2|9|35*4|(4|35*6)(3|[29]5*6)*(1|8|[29]5*4)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4)))|(5|[18]5*[29]|(2|9|[18]5*6)(3|[29]5*6)*(6|[29]5*[29])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(4|[18]5*[18]|(2|9|[18]5*6)(3|[29]5*6)*(5|[29]5*[18])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))(4|[07]5*[29]|(1|8|[07]5*6)(3|[29]5*6)*(6|[29]5*[29])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))*(6|[07]5*4|(1|8|[07]5*6)(3|[29]5*6)*(1|8|[29]5*4)|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(2|9|35*4|(4|35*6)(3|[29]5*6)*(1|8|[29]5*4)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))))|(6|[18]5*3|(2|9|[18]5*6)(3|[29]5*6)*(0|7|[29]5*3)|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3))|(4|[18]5*[18]|(2|9|[18]5*6)(3|[29]5*6)*(5|[29]5*[18])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(1|8|35*3|(4|35*6)(3|[29]5*6)*(0|7|[29]5*3)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3)))|(5|[18]5*[29]|(2|9|[18]5*6)(3|[29]5*6)*(6|[29]5*[29])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(4|[18]5*[18]|(2|9|[18]5*6)(3|[29]5*6)*(5|[29]5*[18])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))(4|[07]5*[29]|(1|8|[07]5*6)(3|[29]5*6)*(6|[29]5*[29])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))*(5|[07]5*3|(1|8|[07]5*6)(3|[29]5*6)*(0|7|[29]5*3)|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(1|8|35*3|(4|35*6)(3|[29]5*6)*(0|7|[29]5*3)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3)))))(2|9|45*3|(5|45*6)(3|[29]5*6)*(0|7|[29]5*3)|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3))|(0|7|45*[18]|(5|45*6)(3|[29]5*6)*(5|[29]5*[18])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(1|8|35*3|(4|35*6)(3|[29]5*6)*(0|7|[29]5*3)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3)))|(1|8|45*[29]|(5|45*6)(3|[29]5*6)*(6|[29]5*[29])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(0|7|45*[18]|(5|45*6)(3|[29]5*6)*(5|[29]5*[18])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))(4|[07]5*[29]|(1|8|[07]5*6)(3|[29]5*6)*(6|[29]5*[29])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))*(5|[07]5*3|(1|8|[07]5*6)(3|[29]5*6)*(0|7|[29]5*3)|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(1|8|35*3|(4|35*6)(3|[29]5*6)*(0|7|[29]5*3)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(4|65*3|(0|7|65*6)(3|[29]5*6)*(0|7|[29]5*3)))))*(3|45*4|(5|45*6)(3|[29]5*6)*(1|8|[29]5*4)|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))|(0|7|45*[18]|(5|45*6)(3|[29]5*6)*(5|[29]5*[18])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(2|9|35*4|(4|35*6)(3|[29]5*6)*(1|8|[29]5*4)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4)))|(1|8|45*[29]|(5|45*6)(3|[29]5*6)*(6|[29]5*[29])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(0|7|45*[18]|(5|45*6)(3|[29]5*6)*(5|[29]5*[18])|(6|45*[07]|(5|45*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))(4|[07]5*[29]|(1|8|[07]5*6)(3|[29]5*6)*(6|[29]5*[29])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(0|7|35*[29]|(4|35*6)(3|[29]5*6)*(6|[29]5*[29])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))))*(6|[07]5*4|(1|8|[07]5*6)(3|[29]5*6)*(1|8|[29]5*4)|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))|(3|[07]5*[18]|(1|8|[07]5*6)(3|[29]5*6)*(5|[29]5*[18])|(2|9|[07]5*[07]|(1|8|[07]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(2|9|35*4|(4|35*6)(3|[29]5*6)*(1|8|[29]5*4)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))))))* This is tested with The Regex Coach. How We Get There The Regex above produced by first constructing a DFA which would accept the input we want (decimals divisible by 7) and then converting to a Regular Expression and fixing the notation To understand this, it helps to first make a DFA which accepts the following language: L = {w | w is a binary representation of an integer divisible by 7 } That is, it will 'match' binary numbers that are divisible by 7. The DFA looks like this: Mod 7 NFA How it works You keep a current value A that represents the value of the bits the DFA has read. When you read a 0 then A = 2*A and when you read a 1 A = 2*A + 1. At each step you calculate A mod 7 then you go to the state that represents the answer. So a test run We're reading in 10101 which is the binary representation for 21 in decimal. 1. We start at state q0, currently A=0 2. We read a 1, from the 'rule' above A = 2*A + 1 so A = 1. A mod 7 = 1 so we move to state q1 3. We read a 0, A = 2*A = 2, A mod 7 = 2 so we move to q2 4. Read a 1, A = 2*A + 1 = 5, A mod 7 = 5, move to q5 5. Read a 0, A = 2*A = 10, A mod 7 = 3, move to q3 6. Read a 1, A = 2*A + 1 = 21, A mod 7 = 0, move to q0 7. The input is accepted so the number 10101 is divisible by 7! Converting the DFA to a Regular Expression is a tricky task so I got JFLAP to do it for me, producing the following: (0|111|100((1|00)0)*011|(101|100((1|00)0)*(1|00)1)(1((1|00)0)*(1|00)1)*(01|1((1|00)0)*011)|(110|100((1|00)0)*010|(101|100((1|00)0)*(1|00)1)(1((1|00)0)*(1|00)1)*(00|1((1|00)0)*010))(1|0(1((1|00)0)*(1|00)1)*(00|1((1|00)0)*010))*0(1((1|00)0)*(1|00)1)*(01|1((1|00)0)*011))* For Decimal Numbers The process is much the same: I constructed a DFA which accepts the language: L = {w | w is a decimal number that is divisible by 7} Here's the DFA: [StGDs] The logic is similar, same number of states just many more transitions to handle all the extra digits decimal numbers bring. Now the rule to change A at each step is: when you read a decimal digit n: A = 10*A + n. Then again you just mod A by 7 and go to the next state. Revisions Revision 5 The above regular expression now rejects numbers leading zeros - apart from zero itself of course. This makes the DFA slightly different, basically you branch off from the initial node when you read the first zero. Reading another zero puts you into an infinite loop on the branched state. I haven't fixed the diagram to show this. Revision 7 Did some "metaregex" and shortened my regex by replacing some of the unions with character classes. Revision 10 and 11 (by nhahtdh) The author's modification to reject leading zero is incorrect. It makes the regexes fail to match valid numbers, such as 1110 (decimal = 14) in the case of binary regex, and 70 in the case of decimal regex. These revision reverts the modification, and consequently, allows arbitrary leading zeros and empty string to match. This revision increases the size of the decimal regex, since it corrects a bug in the original regex, caused by a missing an edge (9) from state 5 to state 3 in the original DFA. Share Improve this answer Follow edited Dec 11 '21 at 2:57 [nuL] caird coinheringaahing 46.3k99 gold badges9696 silver badges313313 bronze badges answered Aug 19 '11 at 21:24 [mJC] GriffinGriffin 4,67733 gold badges2828 silver badges2929 bronze badges \$\endgroup\$ 14 • \$\begingroup\$ I will clarify the question to specify decimal. Yes, it's much easier in bases b where 7 | b(b-1). \$\endgroup\$ – Charles Aug 19 '11 at 22:14 • \$\begingroup\$ I have amended my answer. Decimal is all good :D \$\ endgroup\$ – Griffin Aug 19 '11 at 22:19 • \$\begingroup\$ Too late for me to amend my comment, though... I meant 7 | B(B-1) where B is a small power of b. Binary has a short regex since 7 | 8 (8-1). Decimal is larger since 7 | 999999000000 is the smallest that works. \$\endgroup\$ – Charles Aug 19 '11 at 23:11 • 3 \$\begingroup\$ btw i think you used DFA, not NFA \$\endgroup\$ – binarycode Dec 23 '13 at 19:02 • 2 \$\begingroup\$ Neither of the regexes shown in this answer are correct. The binary one doesn't match 1110, and the one for decimal doesn't match 70. This was tested in both python and perl. (python required converting every ( to (?: first) \$\endgroup\$ – Daniel Martin Nov 9 '15 at 18:53 | Show 9 more comments 39 \$\begingroup\$ .NET regex, [DEL:119:DEL] [DEL:118:DEL] 105 bytes ^(?>(?=[1468](?<4>)|)(?=[2569](?<4>){2}|)([3-6]()|\d)((?<-2>)(){3}|){7}((?<-4>){7}|(?<2-4>)|){9})+$(?!\2) 111 characters disallowing initial 0s: ^(?!0.)(?>(?=[1468](?<4>)|)(?=[2569](?<4>){2}|)([3-6]()|\d)((?<-2>)(){3}|){7}((?<-4>){7}|(?<2-4>)|){9})+$(?!\2) 113 characters disallowing initial 0s and supporting negative numbers: ^-?(?>(?=[1468](?<4>)|)(?=[2569](?<4>){2}|)([3-6]()|\d)((?<-2>)(){3}|){7}((?<-4>){7}|(?<2-4>)|){9})+$(?!\2) Try it here. Explanation (of the previous version) It uses the techniques used by various answers in this question: Cops and Robbers: Reverse Regex Golf. The .NET regex has a feature called balancing group, which can be used for doing arithmetic. (?) pushes a group a. (?<-a>) pops that and doesn't match if there isn't a group a matched before. • (?>...) Match and don't backtrack later. So it will always match only the first matched alternative. • ((?<-t>)(){3}|){6} Multiply the number of group t by 3. Save the result in the number of group 2. • (?=[1468](?<2>)|)(?=[2569](?<2>){2}|)([3-6](?<2>){3}|\d) Match a number, and that number of group 2. • ((?<-2>){7}|){3} Remove group 2 a multiple of 7 times. • ((?)|){6} Remove group 2 and match the same number of group t. • $(?(t)a) If there is still a group t matched, match a after the end of string, which is impossible. I thought this 103 byte version should also work, but didn't find a workaround of the bug in the compiler. ^(?(?(?((?<3>){2}[2569]|)([3-6])?((?<-1>)(){3}|){7})(?<3>[1468])?((?<-3>){7}|(?<1-3>)|){9})\d)+$(?(1)a) Share Improve this answer Follow edited Jun 17 '20 at 9:04 [a00] CommunityBot 1 answered Oct 25 '14 at 3:01 [Ynx] jimmy23013jimmy23013 35.5k66 gold badges7171 silver badges140140 bronze badges \$\endgroup\$ 6 • \$\begingroup\$ Very short. I'd love an explanation of how this works! \$\ endgroup\$ – Charles Oct 25 '14 at 23:13 • \$\begingroup\$ @Charles Edited. \$\endgroup\$ – jimmy23013 Oct 26 '14 at 3:36 • \$\begingroup\$ I don't think this is gonna be beaten, but I prefer at least having to implement the DFA with recursion, this is just insane. I wonder if someone can prove or disprove .NET regexes as Turing complete. \$ \endgroup\$ – ThePlasmaRailgun Feb 27 '19 at 5:48 • \$\begingroup\$ @ThePlasmaRailgun .NET regex is not Turing complete, because it doesn't allow repeating empty captures more than the lower bound (example). So each group with quantifiers could have only a finite number of alternatives if the input has a fixed length. \$\endgroup\$ – jimmy23013 Feb 27 '19 at 9:48 • \$\begingroup\$ Ah. Without that bound, would it be Turing complete? \$\ endgroup\$ – ThePlasmaRailgun Feb 27 '19 at 17:31 | Show 1 more comment 32 \$\begingroup\$ 468 characters Ruby's regex flavor allows recursion (although it's sort of cheating), so it is straightforward to implement a DFA that recognizes numbers divisible by 7 using that. Each named group corresponds to a state, and each branch in the alternations consumes one digit and then jumps to the appropriate state. If the end of the number is reached, the regex matches only if the engine is in the "A" group, otherwise it fails. It recognizes leading zeros. (?!$)(?>(|(?4\g|5\g|6\g|[07]\g|[18]\g|[29]\g|3\g))(|(?[18]\g|[29]\g|3\g|4\g|5\g|6\g|[07]\g))(|(?5\g|6\g|[07]\g|[18]\g|[29]\g|3\g|4\g))(|(?[29]\g|3\g|4\g|5\g|6\g|[07]\g|[18]\g))(|(?6\g|[07]\g|[18]\g|[29]\g|3\g|4\g|5\g))(|(?3\g|4\g|5\g|6\g|[07]\g|[18]\g|[29]\g)))(?$|[07]\g|[18]\g|[29]\g|3\g|4\g|5\g|6\g) Share Improve this answer Follow edited Aug 21 '11 at 13:00 answered Aug 21 '11 at 12:10 [eef] LowjackerLowjacker 4,78411 gold badge1616 silver badges1919 bronze badges \$\endgroup\$ 4 • 3 \$\begingroup\$ I had intended to disallow that, but I guess I didn't. This allows for very short solutions in Ruby, Perl, PCRE, and .NET languages. \$ \endgroup\$ – Charles Aug 21 '11 at 17:13 • 2 \$\begingroup\$ recursion makes it a context-free grammar (if it can decide {a*b*|a and b an equal amount of times}) \$\endgroup\$ – ratchet freak Aug 21 '11 at 19:38 • \$\begingroup\$ @ratchet freak: I know that this technically isn't a regular expression, but the question states that any regex flavor is acceptable. \$\endgroup\$ – Lowjacker Aug 21 '11 at 20:09 • \$\begingroup\$ I made a generator based on your post that creates these for arbitrary divisors and bases: github.com/ThePlasmaRailgun/ DivisibilityRegexes. It also has the option to generate the .jff files for JFLAP. \$\endgroup\$ – ThePlasmaRailgun Feb 27 '19 at 5:27 Add a comment | 28 \$\begingroup\$ 10791 characters, leading zeros allowed (0|7|46*[29]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(4|63*[18]|(1|8|63*5)(6|43*5)*(2|9|43*[18]))|(2|9|46*4)(3|56*4)*(1|8|56*[29])|(3|46*5|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4))|(2|9|46*4)(3|56*4)*(4|56*5)|(5|46*[07]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(2|9|46*4)(3|56*4)*(6|56*[07]))(4|36*[07]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4))|(1|8|36*4)(3|56*4)*(4|56*5)))(1|8|(0|7|[29]6*4)(3|56*4)*(4|56*5)|[29]6*5|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))*(5|34*6|(0|7|34*[18]|(2|9|34*3)(6|[07]4*3)*(4|[07]4*[18]))(3|56*4|(6|56*[07])(4|36*[07])*(1|8|36*4))*(1|8|64*6|(5|64*3)(6|[07]4*3)*(2|9|[07]4*6))|(2|9|34*3)(6|[07]4*3)*(2|9|[07]4*6)|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(4|63*[18]|(1|8|63*5)(6|43*5)*(2|9|43*[18])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(6|36*[29]|(1|8|36*4)(3|56*4)*(1|8|56*[29]))))|(5|46*[07]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(2|9|46*4)(3|56*4)*(6|56*[07]))(4|36*[07]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(1|8|36*4)(3|56*4)*(6|56*[07]))*(6|36*[29]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(4|63*[18]|(1|8|63*5)(6|43*5)*(2|9|43*[18]))|(1|8|36*4)(3|56*4)*(1|8|56*[29]))|(6|46*[18]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(3|63*[07]|(1|8|63*5)(6|43*5)*(1|8|43*[07]))|(2|9|46*4)(3|56*4)*(0|7|56*[18])|(3|46*5|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4))|(2|9|46*4)(3|56*4)*(4|56*5)|(5|46*[07]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(2|9|46*4)(3|56*4)*(6|56*[07]))(4|36*[07]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4))|(1|8|36*4)(3|56*4)*(4|56*5)))(1|8|(0|7|[29]6*4)(3|56*4)*(4|56*5)|[29]6*5|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))*(4|34*5|(0|7|34*[18]|(2|9|34*3)(6|[07]4*3)*(4|[07]4*[18]))(3|56*4|(6|56*[07])(4|36*[07])*(1|8|36*4))*(0|7|64*5|(5|64*3)(6|[07]4*3)*(1|8|[07]4*5))|(2|9|34*3)(6|[07]4*3)*(1|8|[07]4*5)|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(3|63*[07]|(1|8|63*5)(6|43*5)*(1|8|43*[07])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(5|36*[18]|(1|8|36*4)(3|56*4)*(0|7|56*[18]))))|(5|46*[07]|(1|8|46*3|(2|9|46*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(2|9|46*4)(3|56*4)*(6|56*[07]))(4|36*[07]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))|(1|8|36*4)(3|56*4)*(6|56*[07]))*(5|36*[18]|(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(3|63*[07]|(1|8|63*5)(6|43*5)*(1|8|43*[07]))|(1|8|36*4)(3|56*4)*(0|7|56*[18])))(2|9|53*[07]|(0|7|53*5)(6|43*5)*(1|8|43*[07])|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(5|36*[18]|(1|8|36*4)(3|56*4)*(0|7|56*[18]))|(4|[07]6*3|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(5|[07]6*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(3|63*[07]|(1|8|63*5)(6|43*5)*(1|8|43*[07])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(5|36*[18]|(1|8|36*4)(3|56*4)*(0|7|56*[18])))|(6|53*4|(0|7|53*5)(6|43*5)*(5|43*4)|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(4|[07]6*3|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(5|[07]6*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))(1|8|(0|7|[29]6*4)(3|56*4)*(4|56*5)|[29]6*5|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))*(4|34*5|(0|7|34*[18]|(2|9|34*3)(6|[07]4*3)*(4|[07]4*[18]))(3|56*4|(6|56*[07])(4|36*[07])*(1|8|36*4))*(0|7|64*5|(5|64*3)(6|[07]4*3)*(1|8|[07]4*5))|(2|9|34*3)(6|[07]4*3)*(1|8|[07]4*5)|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(3|63*[07]|(1|8|63*5)(6|43*5)*(1|8|43*[07])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(5|36*[18]|(1|8|36*4)(3|56*4)*(0|7|56*[18])))))*(3|53*[18]|(0|7|53*5)(6|43*5)*(2|9|43*[18])|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(6|36*[29]|(1|8|36*4)(3|56*4)*(1|8|56*[29]))|(4|[07]6*3|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(5|[07]6*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(4|63*[18]|(1|8|63*5)(6|43*5)*(2|9|43*[18])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(6|36*[29]|(1|8|36*4)(3|56*4)*(1|8|56*[29])))|(6|53*4|(0|7|53*5)(6|43*5)*(5|43*4)|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(4|[07]6*3|(1|8|53*6|(0|7|53*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(5|[07]6*4)(3|56*4)*(2|9|56*3))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))(1|8|(0|7|[29]6*4)(3|56*4)*(4|56*5)|[29]6*5|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(0|7|63*4|(1|8|63*5)(6|43*5)*(5|43*4)|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(2|9|36*5|(1|8|36*4)(3|56*4)*(4|56*5))))*(5|34*6|(0|7|34*[18]|(2|9|34*3)(6|[07]4*3)*(4|[07]4*[18]))(3|56*4|(6|56*[07])(4|36*[07])*(1|8|36*4))*(1|8|64*6|(5|64*3)(6|[07]4*3)*(2|9|[07]4*6))|(2|9|34*3)(6|[07]4*3)*(2|9|[07]4*6)|(6|(0|7|[29]6*4)(3|56*4)*(2|9|56*3)|[29]6*3|(3|[07]3*6|(2|9|[07]3*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3)))(5|[18]6*3|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(0|7|36*3|(1|8|36*4)(3|56*4)*(2|9|56*3))|(6|[18]6*4)(3|56*4)*(2|9|56*3))*(4|63*[18]|(1|8|63*5)(6|43*5)*(2|9|43*[18])|(2|9|63*6|(1|8|63*5)(6|43*5)*(0|7|43*6))(4|36*[07]|(1|8|36*4)(3|56*4)*(6|56*[07]))*(6|36*[29]|(1|8|36*4)(3|56*4)*(1|8|56*[29]))))))+ 10795 characters, leading zeros forbidden 0|((foo)0*)+, where the above regex is (0|foo)+. Explanation Numbers divisible by 7 are matched by the obvious finite automaton with 7 states Q = {0, …, 6}, initial and final state 0, and transitions d: i ↦ (10i + d) mod 7. I converted this finite automaton into a regular expression, using recursion on the set of allowed intermediate states: Given i, j ∈ Q and S ⊆ Q, let f(i, S, j) be a regular expression that matches all automaton paths from i to j using only intermediate states within S. Then, f(i, ∅, j) = (j − 10i) mod 7, f(i, S ∪ {k}, j) = f(i, S, j) ∣ f(i, S, k) f(k, S, k)* f(k, S, j). I used dynamic programming to choose k so as to minimize the length of the resulting expression. Share Improve this answer Follow edited Mar 16 '16 at 18:18 answered Mar 10 '16 at 23:17 [iGs] Anders KaseorgAnders Kaseorg 35.7k33 gold badges6464 silver badges129129 bronze badges \$\endgroup\$ 2 • \$\begingroup\$ I think you have to add 2 character for in the leading zero case, since I guess zero has to be allowed 0|((foo)0*)+ \$\endgroup\$ – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Mar 16 '16 at 3:05 • 3 \$\begingroup\$ I have commented on the question, but by common sense, "no leading zero" usually means that no redundant leading 0, but it does not exclude the number zero. \$\endgroup\$ – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Mar 16 '16 at 3:56 Add a comment | 25 \$\begingroup\$ I was really impressed by Griffin's answer and needed to figure out how it worked! The result is the following JavaScript. (It's 3.5k characters, which is shorter in a way!) The gen function takes a divisor and base and generates a regular expression that matches numbers in the specified base that are divisible by that divisor. I've generalized Griffin's NFA for any base: the nfa function takes a divisor and base and returns a two dimensional array of transitions. The input required to go from state 0 to state 2, for example, is states[0][2] == "1". The reduce function takes in the states array and runs it through this algorithm to translate the NFA to regex. The regexes that are generated are huge and look like they have a lot of redundant clauses, despite my attempts at optimization. The regex for 7 base 10 is about ~67k characters long; Firefox throws an "InternalError" for n > 5 trying to parse the regex; running the regex on Chrome starts getting slow for n > 6. There's also the test function that takes a regex and base and runs it against the numbers 0 to 100, so test(gen(5)) == [0, 5, 10, 15, ...]. Despite the suboptimal result, this was a fantastic learning opportunity, and I hope some of this code will be useful in the future! function gen(b, base) { var states = nfa(b, base) for (var i = 0; i < states.length; i++) states = reduce(states, i); return states[0][0] != 'phi' && new RegExp('^' + wrap(states[0][0]) + '$'); } function test(reg, base) { if (!base) base = 10; var x = []; for (var i = 0; i < 100; i++) x.push(i); return x.map(function (a) {return a.toString(base)}).filter(reg.test.bind(reg)).map(function (a) {return parseInt(a, base)}) } function nfa(b, base) { if (!base) base = 10; var states = []; for (var i = 0; i < b; i++) { states[i] = []; for (var j = 0; j < b; j++) states[i][j] = []; } for (var i = 0; i < b; i++) for (var n = 0; n < base; n++) states[i][(i * base + n) % b].push(n.toString()); for (var i = 0; i < b; i++) for (var j = 0; j < b; j++) states[i][j] = states[i][j].length > 1 ? '[' + states[i][j].join('') + ']' : (states[i][j][0] || 'phi'); return states; } // http://www.cs.umbc.edu/~squire/cs451_l7.html function reduce(states, n) { var s = states.length; var reduced = []; for (var i = 0; i < s; i++) { reduced[i] = []; for (var j = 0; j < s; j++) { // reduced[i][j] = wrap(states[i][n] + wrap(states[n][n]) + '*' + states[n][j] + '|' + states[i][j]); reduced[i][j] = ''; if (states[i][n] == 'phi' || states[n][j] == 'phi') { reduced[i][j] = states[i][j]; continue; } if (states[i][n] != states[n][n]) reduced[i][j] += wrap(states[i][n]); if (states[n][n] != 'phi') { reduced[i][j] += wrap(states[n][n]); if (states[i][n] == states[n][n] && states[n][j] == states[n][n]) reduced[i][j] += wrap(states[n][n]); if (states[i][n] == states[n][n] || states[n][j] == states[n][n]) reduced[i][j] += '+'; else reduced[i][j] += '*'; } if (states[n][j] != states[n][n]) reduced[i][j] += wrap(states[n][j]); reduced[i][j] = states[i][j] == 'phi' ? wrap(reduced[i][j]) : alternate(reduced[i][j], states[i][j]); } } return reduced; } function matching(x, open, close) { // Test if the parens are actually matching if ('(['.indexOf(x.charAt(open)) != -1 && ')]'.indexOf(x.charAt(close)) != -1) { var count = 0; for (var i = open; i <= close; i++) { if ('(['.indexOf(x.charAt(i)) != -1) count++; else if (')]'.indexOf(x.charAt(i)) != -1) { count--; if (count == 0) return i == close; } } } return false; } function wrap(x) { if (x.length < 2 || matching(x, 0, x.length - 1)) return x; return '(' + x + ')'; } function optional(cond) { if (matching(cond, 0, cond.length - 2)) { var op = cond.charAt(cond.length - 1); if (op == '+') return cond.slice(0, -1) + '*'; else if (op == '*' || op == '?') return cond; } else if (matching(cond, 0, cond.length - 1)) return optional(cond.slice(1, -1)); return wrap(cond) + '?'; } function alternate(cond1, cond2) { cond2 = wrap(cond2); var index = cond1.indexOf(cond2); var len = cond2.length; var cond = ''; if (index == 0) { var op = cond1.charAt(len); if (op == '*') cond = cond2 + '+' + optional(cond1.slice(len)); else if (op == '+') cond = cond1; else cond = cond2 + optional(cond1.slice(len)); } else if (index == cond1.length - len) cond = optional(cond1.slice(0, index)) + cond2; else if (cond1.length == 1 && cond2.length == 1) cond = '[' + cond1 + cond2 + ']'; else cond = cond1 + '|' + cond2; return wrap(cond); } Share Improve this answer Follow edited Mar 10 '16 at 21:30 [wQr] mbomb007 22.7k66 gold badges5555 silver badges132132 bronze badges answered Aug 28 '11 at 8:52 [1ff] Casey ChuCasey Chu 1,7411212 silver badges1010 bronze badges \$\endgroup\$ Add a comment | 9 \$\begingroup\$ Perl/PCRE, 370 characters ^(?!$|0.)([07]*(?:[18](?2)|[29](?3)|3(?4)|4(?5)|5(?7)|6(?9)|$))|(5*(?:[07](?4)|[18](?5)|[29](?7)|4(?1)|6(?3)|3(?9)))(3*(?:[18](?1)|[29](?2)|[07](?9)|4(?4)|5(?5)|6(?7)))([18]*(?:[07](?3)|[29](?5)|5(?1)|6(?2)|3(?7)|4(?9)))(6*([29](?1)|[07](?7)|[18](?9)|3(?2)|4(?3)|5(?4)))(4*([07](?2)|[18](?3)|[29](?4)|6(?1)|3(?5)|5(?9)))([29]*([07](?5)|[18](?7)|3(?1)|4(?2)|5(?3)|6(?4))) Rejects the empty string, as well as strings with leading 0’s (except "0"). Share Improve this answer Follow edited Mar 16 '16 at 2:43 [d09] n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ 5,8552323 silver badges4141 bronze badges answered Mar 10 '16 at 20:41 [164] GrimmyGrimmy 15.3k11 gold badge2727 silver badges6161 bronze badges \$\endgroup\$ 1 • \$\begingroup\$ @Charles This is valid PHP PCRE, and does indeed work to validate divisibility -- try it here \$\endgroup\$ – cat Mar 10 '16 at 22:56 Add a comment | Your Answer [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] If this is an answer to a challenge… • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead. • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one. Explanations of your answer make it more interesting to read and are very much encouraged. • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge. More generally… • …Please make sure to answer the question and provide sufficient detail. • …Avoid asking for help, clarification or responding to other answers (use comments instead). Draft saved Draft discarded [ ] Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Submit Post as a guest Name [ ] Email Required, but never shown [ ] Post as a guest Name [ ] Email Required, but never shown [ ] Post Your Answer Discard By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy Not the answer you're looking for? Browse other questions tagged code-golf math regular-expression or ask your own question. Welcome to Code Golf and Coding Challenges Stack Exchange! This is a site for recreational programming competitions, not general programming questions. Challenges must have an objective scoring criterion, and it is highly recommended to first post proposed challenges in the Sandbox. The Overflow Blog • Psychological safety is critical for high-performing teams • Using synthetic data to power machine learning while protecting user privacy Upcoming Events • Language of the Month - Add++ January 2022 Featured on Meta • We’ve made changes to our Terms of Service & Privacy Policy - January 2022 • New post summary designs on site home pages and greatest hits now; everywhere... • Best of CGCC 2021 - Now Accepting Nominations! Linked 75 Cops and Robbers: Reverse Regex Golf 16 ValiDate ISO 8601 by RX 14 Regex for multiples of 9 Related 30 Meta regex golf 11 Regex for Finding Radioactive Elements 3 Regex for Finding Non-Radioactive Elements 41 A Different Kind of Meta Regex Golf 48 Tips for Regex Golf 19 Regex: Match an egalitarian series 14 Regex for multiples of 9 5 Regex golf and ccTLDs, hooray! Hot Network Questions • Are rounds just for combat, or should we be using them at other times in the game? • What part of speech is "freezing" in this sentence: "He will not see again the freezing kitchenhouse..." • What is the most general form of Hurwitz's theorem in complex analysis? • Why don't errors accumulate in climate models when the time horizon increases? • What are the other ways of energy transfer apart from heat and work? • What is the origin of the joke 'a freckle past a hair' when one is asked the time of day? • A Faulty Number Trick • Why does "just intonation" make it so different keys have different characteristics? • How did 455 kHz end up being a commonly used IF (intermediate frequency)? • Can you walk in deep water with waterproof clothing? • 1970s live action Spider-Man TV series fancy dress/costume party episode • what does ls / > mean? • What is お互い自分の知恵裁量? • Please tell me how to formalize my thought if my thought is not wrong. ("obvious by symmetry", "symmetric group") • Meaning of four/five digit/letter codes on passport stamps • Non-yielding scheduler error in large memory server if the lock pages in memory option is disabled • Book named "Someone"'s War, in which complex technology is outlawed with religious fervor • What would be the likely indication on the VOR for the below question? • Is this ship resurrection spell balanced for 4th level? • Did the Macintosh OS in 1997 really not have multitasking? • I factory reset my m1 macbook, it still contained my name =( • How to get better topology on a Ellipse corner • How would you protect yourself from the Negative Plane? • What's the difference between 650x48B and 650x47C? more hot questions Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. [https://codegolf.sta] * Code Golf • Tour • Help • Chat • Contact • Feedback • Mobile Company • Stack Overflow • For Teams • Advertise With Us • Hire a Developer • Developer Jobs • About • Press • Legal • Privacy Policy • Terms of Service • Cookie Settings • Cookie Policy Stack Exchange Network • Technology • Culture & recreation • Life & arts • Science • Professional • Business • API • Data • Blog • Facebook • Twitter • LinkedIn • Instagram site design / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2022.1.28.41306 Code Golf Stack Exchange works best with JavaScript enabled [p] Your privacy By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Accept all cookies Customize settings