-
Notifications
You must be signed in to change notification settings - Fork 2
/
RandomCNF.py
35 lines (24 loc) · 850 Bytes
/
RandomCNF.py
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
33
34
35
from itertools import combinations
import random
import sys
def create_CNF(k, m, n, output):
symbol_list = []
for i in range(26):
symbol_list.append(chr(i + 65))
for i in range(26):
symbol_list.append(chr(i + 97))
symbol = symbol_list[:n]
for i in range(len(symbol)):
symbol.append('!' + symbol[i])
clause_comb_symbol = list(combinations(list(combinations(symbol, k)), m))
CNF = clause_comb_symbol[random.randint(0, len(clause_comb_symbol) - 1)]
for i in CNF:
print(' '.join(i).strip(' '))
output.write(' '.join(i).strip(' '))
if i != CNF[len(CNF) - 1]:
output.write('\n')
def main():
output = open('sampleCNF/output.txt', 'w')
create_CNF(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), output)
if __name__ == '__main__':
main()