From 1c27f176779663d56faffa570968b4bcaa06aaf8 Mon Sep 17 00:00:00 2001 From: relikd Date: Fri, 12 Feb 2021 00:54:50 +0100 Subject: [PATCH] split folder into db and results --- .gitignore | 4 ++-- LP/InterruptDB.py | 6 +++--- LP/InterruptIndices.py | 4 ++-- LP/LPath.py | 14 +++++++------- {InterruptDB => db}/README.md | 7 +++++++ {InterruptDB => db}/db_high.txt | 0 {InterruptDB => db}/db_high_secondary.txt | 0 {InterruptDB => db}/db_indices.txt | 0 {InterruptDB => db}/db_norm.txt | 0 {InterruptDB => db}/db_norm_secondary.txt | 0 {InterruptDB => results}/index.html | 0 {InterruptDB => results}/index_high.html | 0 {InterruptDB => results}/index_norm.html | 0 {InterruptDB => results}/template.html | 0 solver.py | 6 +++--- 15 files changed, 24 insertions(+), 17 deletions(-) rename {InterruptDB => db}/README.md (68%) rename {InterruptDB => db}/db_high.txt (100%) rename {InterruptDB => db}/db_high_secondary.txt (100%) rename {InterruptDB => db}/db_indices.txt (100%) rename {InterruptDB => db}/db_norm.txt (100%) rename {InterruptDB => db}/db_norm_secondary.txt (100%) rename {InterruptDB => results}/index.html (100%) rename {InterruptDB => results}/index_high.html (100%) rename {InterruptDB => results}/index_norm.html (100%) rename {InterruptDB => results}/template.html (100%) diff --git a/.gitignore b/.gitignore index 641e6ac..42c143f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ __pycache__/ -data/oeis_orig.txt -data/oeis.txt +db/oeis_orig.txt +db/oeis.txt other/ec-*.png other/ec-*.txt other/list-onions.txt diff --git a/LP/InterruptDB.py b/LP/InterruptDB.py index 24bcf5e..87fc282 100755 --- a/LP/InterruptDB.py +++ b/LP/InterruptDB.py @@ -54,10 +54,10 @@ class InterruptDB(object): @staticmethod def load(dbname): - if not os.path.isfile(LPath.InterruptDB(dbname)): + if not os.path.isfile(LPath.db(dbname)): return {} ret = {} - with open(LPath.InterruptDB(dbname), 'r') as f: + with open(LPath.db(dbname), 'r') as f: for line in f.readlines(): if line.startswith('#'): continue @@ -73,7 +73,7 @@ class InterruptDB(object): @staticmethod 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)) f.write(f'{name}|{irpmax}|{score:.5f}|{irp}|{keylen}|{nums}\n') diff --git a/LP/InterruptIndices.py b/LP/InterruptIndices.py index f2f2f70..3615c87 100755 --- a/LP/InterruptIndices.py +++ b/LP/InterruptIndices.py @@ -28,7 +28,7 @@ class InterruptIndices(object): @staticmethod 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') for name in FILES_ALL: data = load_indices(LPath.page(name), 0) @@ -42,7 +42,7 @@ class InterruptIndices(object): @staticmethod def load(dbname='db_indices'): - with open(LPath.InterruptDB(dbname), 'r') as f: + with open(LPath.db(dbname), 'r') as f: ret = {} for line in f.readlines(): if line.startswith('#'): diff --git a/LP/LPath.py b/LP/LPath.py index f635cc7..632da24 100755 --- a/LP/LPath.py +++ b/LP/LPath.py @@ -27,13 +27,13 @@ class LPath(object): return os.path.join(LP_ROOT_DIR, 'data', f'{fname}.{ext}') @staticmethod - def tmp(fname, ext='txt'): - return os.path.join(LP_ROOT_DIR, 'tmp', f'{fname}.{ext}') - - @staticmethod - def InterruptDB(fname): - return os.path.join(LP_ROOT_DIR, 'InterruptDB', fname + '.txt') + def db(fname): + return os.path.join(LP_ROOT_DIR, 'db', fname + '.txt') @staticmethod 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}') diff --git a/InterruptDB/README.md b/db/README.md similarity index 68% rename from InterruptDB/README.md rename to db/README.md index 68a5d10..31be205 100644 --- a/InterruptDB/README.md +++ b/db/README.md @@ -1,3 +1,4 @@ +### InterruptDB - `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 @@ -6,3 +7,9 @@ - `db_indices` : Just each index of each rune for all chapters _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 \ No newline at end of file diff --git a/InterruptDB/db_high.txt b/db/db_high.txt similarity index 100% rename from InterruptDB/db_high.txt rename to db/db_high.txt diff --git a/InterruptDB/db_high_secondary.txt b/db/db_high_secondary.txt similarity index 100% rename from InterruptDB/db_high_secondary.txt rename to db/db_high_secondary.txt diff --git a/InterruptDB/db_indices.txt b/db/db_indices.txt similarity index 100% rename from InterruptDB/db_indices.txt rename to db/db_indices.txt diff --git a/InterruptDB/db_norm.txt b/db/db_norm.txt similarity index 100% rename from InterruptDB/db_norm.txt rename to db/db_norm.txt diff --git a/InterruptDB/db_norm_secondary.txt b/db/db_norm_secondary.txt similarity index 100% rename from InterruptDB/db_norm_secondary.txt rename to db/db_norm_secondary.txt diff --git a/InterruptDB/index.html b/results/index.html similarity index 100% rename from InterruptDB/index.html rename to results/index.html diff --git a/InterruptDB/index_high.html b/results/index_high.html similarity index 100% rename from InterruptDB/index_high.html rename to results/index_high.html diff --git a/InterruptDB/index_norm.html b/results/index_norm.html similarity index 100% rename from InterruptDB/index_norm.html rename to results/index_norm.html diff --git a/InterruptDB/template.html b/results/template.html similarity index 100% rename from InterruptDB/template.html rename to results/template.html diff --git a/solver.py b/solver.py index dfc1039..5cf656a 100755 --- a/solver.py +++ b/solver.py @@ -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 trim_orig_oeis(minlen=15, trim=40): # download and unzip: https://oeis.org/stripped.gz - with open(LP.path.data('oeis_orig'), 'r') as f_in: - with open(LP.path.data('oeis'), 'w') as f_out: + with open(LP.path.db('oeis_orig'), 'r') as f_in: + with open(LP.path.db('oeis'), 'w') as f_out: for line in f_in.readlines(): if line[0] == '#': 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') # 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 = [] for line in f.readlines(): vals = line.split(',')