def read_cnf(path):
clauses = []<EOL>for line in open(path):<EOL><INDENT>parts = line.split()<EOL>if not parts or parts[<NUM_LIT:0>] == '<STR_LIT:c>':<EOL><INDENT>continue<EOL><DEDENT>if parts[<NUM_LIT:0>] == '<STR_LIT:p>':<EOL><INDENT>assert len(parts) == <NUM_LIT:4><EOL>assert parts[<NUM_LIT:1>] == '<STR_LIT>'<EOL>n_vars, n_clauses = [int(n) for n in parts[<NUM_LIT:2>:<NUM_LIT:4>]]<EOL>continue<EOL><DEDENT>if parts[<NUM_LIT:0>] == '<STR_LIT:%>':<EOL><INDENT>break<EOL><DEDENT>assert parts[-<NUM_LIT:1>] == '<STR_LIT:0>'<EOL>clauses.append([int(lit) for lit in parts[:-<NUM_LIT:1>]])<EOL><DEDENT>assert len(clauses) == n_clauses<EOL>return clauses, n_vars<EOL>
read a DIMACS cnf formatted file from `path`, and return the clauses
and number of variables