fix few small things

This commit is contained in:
relikd
2021-02-13 22:24:17 +01:00
parent e4b4ed4498
commit 8ae643126e
3 changed files with 3 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ class Probability(object):
self.prob = [0] * 29
for r in numstream:
self.prob[r] += 1
self.N = len(numstream)
self.N = sum(self.prob)
def IC(self):
X = sum(x * (x - 1) for x in self.prob)

View File

@@ -92,7 +92,7 @@ class RuneText(object):
def __invert__(self):
return RuneText([~x for x in self._data])
def __str__(self):
def __repr__(self):
return f'RuneText<{len(self)}>'
@property

View File

@@ -39,7 +39,7 @@ def break_cipher(fname, candidates, solver, key_fn):
outfmt = 'IoC: {}, interrupt: {}, count: {}, solver: {}'
for irp_count, score, irp, kl, skips in candidates:
stops, upto = db_i.consider(fname, irp, irp_count)
stops, upto = db_i.consider(fname, 28 - irp if INVERT else irp, irp_count)
print(outfmt.format(score, LP.RUNES[irp], len(stops), key_fn.__name__))
testcase = data[:upto]
for x in reversed(skips):