-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-regexp_div7.py
More file actions
32 lines (23 loc) · 1.21 KB
/
2-regexp_div7.py
File metadata and controls
32 lines (23 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import re
# REGEXP = '(0*|1(0(111|01)*(00|110))*(1|0(111|01)*10)(01*0(0|11(111|01)*10|(10|11(111|01)*(00|110))(0(111|01)*(00|110))*(1|0(111|01)*10)))*1)*'
REGEXP = '\A((0|1(0(111|01)*(00|110))*(1|0(111|01)*10)(01*0(0|11(111|01)*10|(10|11(111|01)*(00|110))(0(111|01)*(00|110))*(1|0(111|01)*10)))*1)0*)+\Z'
# for i in range(0, 10000):
# if (re.fullmatch(REGEXP, '{:b}'.format(i)) != None) != (i%7 == 0):
# print(i)
rgx = re.compile(REGEXP)
# num = 0
# while bool(rgx.match(bin(num)[2:])) == (num%7 == 0):
# num += 1
# print('Testing for: '+str(num))
# print(bin(num)[2:])
# print(bool(rgx.match(bin(num)[2:])),num%7 == 0)
for num in range(0,50001):
if bool(rgx.match(bin(num)[2:])) != (num%7 == 0):
print('Testing for: '+str(num))
print(bin(num)[2:])
print(rgx.match(bin(num)[2:]),num%7 == 0)
# *1(0(111|01)*(00|110))*(1|0(111|01)*10)
# 01*0(0|11(111|01)*10|)
# (10|11(111|01)*(00|110))(0(111|01)*(00|110))*(1|0(111|01)*10)
# (0*1(0(111|01)*(00|110))*(1|0(111|01)*10)(01*0(0|11(111|01)*10|(10|11(111|01)*(00|110))(0(111|01)*(00|110))*(1|0(111|01)*10)))*1)*
# (0*|1(0(111|01)*(00|110))*(1|0(111|01)*10)(01*0(0|11(111|01)*10|(10|11(111|01)*(00|110))(0(111|01)*(00|110))*(1|0(111|01)*10)))*1)*