split folder into db and results
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
data/oeis_orig.txt
|
db/oeis_orig.txt
|
||||||
data/oeis.txt
|
db/oeis.txt
|
||||||
other/ec-*.png
|
other/ec-*.png
|
||||||
other/ec-*.txt
|
other/ec-*.txt
|
||||||
other/list-onions.txt
|
other/list-onions.txt
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ class InterruptDB(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(dbname):
|
def load(dbname):
|
||||||
if not os.path.isfile(LPath.InterruptDB(dbname)):
|
if not os.path.isfile(LPath.db(dbname)):
|
||||||
return {}
|
return {}
|
||||||
ret = {}
|
ret = {}
|
||||||
with open(LPath.InterruptDB(dbname), 'r') as f:
|
with open(LPath.db(dbname), 'r') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
@@ -73,7 +73,7 @@ class InterruptDB(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write(name, score, irp, irpmax, keylen, nums, dbname='db_main'):
|
def write(name, score, irp, irpmax, keylen, nums, dbname='db_main'):
|
||||||
with open(LPath.InterruptDB(dbname), 'a') as f:
|
with open(LPath.db(dbname), 'a') as f:
|
||||||
nums = ','.join(map(str, nums))
|
nums = ','.join(map(str, nums))
|
||||||
f.write(f'{name}|{irpmax}|{score:.5f}|{irp}|{keylen}|{nums}\n')
|
f.write(f'{name}|{irpmax}|{score:.5f}|{irp}|{keylen}|{nums}\n')
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class InterruptIndices(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write(dbname='db_indices'):
|
def write(dbname='db_indices'):
|
||||||
with open(LPath.InterruptDB(dbname), 'w') as f:
|
with open(LPath.db(dbname), 'w') as f:
|
||||||
f.write('# file | total runes in file | interrupt | indices\n')
|
f.write('# file | total runes in file | interrupt | indices\n')
|
||||||
for name in FILES_ALL:
|
for name in FILES_ALL:
|
||||||
data = load_indices(LPath.page(name), 0)
|
data = load_indices(LPath.page(name), 0)
|
||||||
@@ -42,7 +42,7 @@ class InterruptIndices(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(dbname='db_indices'):
|
def load(dbname='db_indices'):
|
||||||
with open(LPath.InterruptDB(dbname), 'r') as f:
|
with open(LPath.db(dbname), 'r') as f:
|
||||||
ret = {}
|
ret = {}
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
|
|||||||
14
LP/LPath.py
14
LP/LPath.py
@@ -27,13 +27,13 @@ class LPath(object):
|
|||||||
return os.path.join(LP_ROOT_DIR, 'data', f'{fname}.{ext}')
|
return os.path.join(LP_ROOT_DIR, 'data', f'{fname}.{ext}')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tmp(fname, ext='txt'):
|
def db(fname):
|
||||||
return os.path.join(LP_ROOT_DIR, 'tmp', f'{fname}.{ext}')
|
return os.path.join(LP_ROOT_DIR, 'db', fname + '.txt')
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def InterruptDB(fname):
|
|
||||||
return os.path.join(LP_ROOT_DIR, 'InterruptDB', fname + '.txt')
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def results(fname):
|
def results(fname):
|
||||||
return os.path.join(LP_ROOT_DIR, 'InterruptDB', fname)
|
return os.path.join(LP_ROOT_DIR, 'results', fname)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tmp(fname, ext='txt'):
|
||||||
|
return os.path.join(LP_ROOT_DIR, 'tmp', f'{fname}.{ext}')
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
### InterruptDB
|
||||||
|
|
||||||
- `db_high` : Find IoC combinations that are as high as possible
|
- `db_high` : Find IoC combinations that are as high as possible
|
||||||
- `db_high_secondary` : List of non-optimal solutions with score greater than 1.4
|
- `db_high_secondary` : List of non-optimal solutions with score greater than 1.4
|
||||||
@@ -6,3 +7,9 @@
|
|||||||
- `db_indices` : Just each index of each rune for all chapters
|
- `db_indices` : Just each index of each rune for all chapters
|
||||||
|
|
||||||
_Note:_ All secondary dbs do not include the solutions from the original db.
|
_Note:_ All secondary dbs do not include the solutions from the original db.
|
||||||
|
|
||||||
|
### OEIS
|
||||||
|
|
||||||
|
Download and unzip the OEIS [stripped.gz][1]. Rename the file to `oeis_orig.txt`. Run `trim_orig_oeis()` in `solver.py`, which will generate the `oeis.txt`.
|
||||||
|
|
||||||
|
[1]: https://oeis.org/stripped.gz
|
||||||
@@ -108,8 +108,8 @@ def try_totient_on_unsolved():
|
|||||||
def find_oeis(irp=0, invert=False, offset=0, allow_fails=1, min_match=2):
|
def find_oeis(irp=0, invert=False, offset=0, allow_fails=1, min_match=2):
|
||||||
def trim_orig_oeis(minlen=15, trim=40):
|
def trim_orig_oeis(minlen=15, trim=40):
|
||||||
# download and unzip: https://oeis.org/stripped.gz
|
# download and unzip: https://oeis.org/stripped.gz
|
||||||
with open(LP.path.data('oeis_orig'), 'r') as f_in:
|
with open(LP.path.db('oeis_orig'), 'r') as f_in:
|
||||||
with open(LP.path.data('oeis'), 'w') as f_out:
|
with open(LP.path.db('oeis'), 'w') as f_out:
|
||||||
for line in f_in.readlines():
|
for line in f_in.readlines():
|
||||||
if line[0] == '#':
|
if line[0] == '#':
|
||||||
continue
|
continue
|
||||||
@@ -120,7 +120,7 @@ def find_oeis(irp=0, invert=False, offset=0, allow_fails=1, min_match=2):
|
|||||||
f_out.write(name + ',' + ','.join(vals) + '\n')
|
f_out.write(name + ',' + ','.join(vals) + '\n')
|
||||||
|
|
||||||
# trim_orig_oeis() # create db if not present already
|
# trim_orig_oeis() # create db if not present already
|
||||||
with open(LP.path.data('oeis'), 'r') as f:
|
with open(LP.path.db('oeis'), 'r') as f:
|
||||||
seqs = []
|
seqs = []
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
vals = line.split(',')
|
vals = line.split(',')
|
||||||
|
|||||||
Reference in New Issue
Block a user