"""Compare our lists of RC(n) with the lists in the preprint of Ahmed and Snevily.

The file data/ahmed_snevily_rc_3_13.json contains the lists RC(3), ..., RC(13) from the preprint.
Our lists come from logs/bruteforce_n.log for n = 3, ..., 12 and from data/rc13.json for n = 13.
This script uses only the standard library.
"""
import json, os
published = {int(n): {tuple(p) for p in v} for n, v in json.load(open('data/ahmed_snevily_rc_3_13.json')).items()}
for n in sorted(published):
    if n == 13:
        ours = {tuple(p) for p in json.load(open('data/rc13.json'))}
    else:
        path = f'logs/bruteforce_{n}.log'
        if not os.path.exists(path) or 'RESULT' not in open(path).read():
            print(n, 'no log')
            continue
        ours = {tuple(map(int, line.split())) for line in open(path) if line.strip() and not line.startswith('RESULT')}
    assert ours == published[n], n
    print(f'RC({n}): {len(ours)} permutations. The list is equal to the published list.')
