just a few functions
This commit is contained in:
@@ -64,6 +64,25 @@ class InterruptDB(object):
|
|||||||
name, score, self.irp, self.irp_count, keylen, nums, dbname)
|
name, score, self.irp, self.irp_count, keylen, nums, dbname)
|
||||||
return len(filtered)
|
return len(filtered)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def longest_no_interrupt(data, interrupt, irpmax=0):
|
||||||
|
def add(i):
|
||||||
|
nonlocal ret, prev
|
||||||
|
idx = prev.pop(0)
|
||||||
|
if idx == 0:
|
||||||
|
ret = []
|
||||||
|
ret.append((i - idx, idx))
|
||||||
|
|
||||||
|
prev = [0] * (irpmax + 1)
|
||||||
|
ret = []
|
||||||
|
for i, x in enumerate(data):
|
||||||
|
if x == interrupt:
|
||||||
|
prev.append(i + 1)
|
||||||
|
add(i)
|
||||||
|
add(i + 1)
|
||||||
|
length, pos = max(ret)
|
||||||
|
return pos, length
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(dbname):
|
def load(dbname):
|
||||||
if not os.path.isfile(f'InterruptDB/{dbname}.txt'):
|
if not os.path.isfile(f'InterruptDB/{dbname}.txt'):
|
||||||
@@ -107,6 +126,12 @@ class InterruptIndices(object):
|
|||||||
def total(self, name):
|
def total(self, name):
|
||||||
return self.pos[name]['total']
|
return self.pos[name]['total']
|
||||||
|
|
||||||
|
def longest_no_interrupt(self, name, irp, irpmax=0):
|
||||||
|
irpmax += 1
|
||||||
|
nums = self.pos[name]['pos'][irp] + [self.pos[name]['total']] * irpmax
|
||||||
|
ret = [(y - x, x) for x, y in zip(nums, nums[irpmax:])]
|
||||||
|
return sorted(ret, reverse=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write(dbname='db_indices'):
|
def write(dbname='db_indices'):
|
||||||
with open(f'InterruptDB/{dbname}.txt', 'w') as f:
|
with open(f'InterruptDB/{dbname}.txt', 'w') as f:
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class Rune(object):
|
|||||||
|
|
||||||
class RuneText(object):
|
class RuneText(object):
|
||||||
def __init__(self, anything):
|
def __init__(self, anything):
|
||||||
|
self._rune_sum = None
|
||||||
if not anything:
|
if not anything:
|
||||||
self._data = []
|
self._data = []
|
||||||
elif isinstance(anything, list):
|
elif isinstance(anything, list):
|
||||||
@@ -139,6 +140,8 @@ class RuneText(object):
|
|||||||
|
|
||||||
def trim(self, maxlen):
|
def trim(self, maxlen):
|
||||||
if self._data_len > maxlen:
|
if self._data_len > maxlen:
|
||||||
|
if self._rune_sum > 0:
|
||||||
|
self._rune_sum -= sum(x.prime for x in self._data[maxlen:])
|
||||||
self._data = self._data[:maxlen]
|
self._data = self._data[:maxlen]
|
||||||
self._data_len = maxlen
|
self._data_len = maxlen
|
||||||
|
|
||||||
@@ -204,6 +207,12 @@ class RuneText(object):
|
|||||||
raise IndexError('RuneText length mismatch')
|
raise IndexError('RuneText length mismatch')
|
||||||
return RuneText([x - y for x, y in zip(self._data, other._data)])
|
return RuneText([x - y for x, y in zip(self._data, other._data)])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rune_sum(self):
|
||||||
|
if self._rune_sum is None:
|
||||||
|
self._rune_sum = sum(x.prime for x in self._data)
|
||||||
|
return self._rune_sum
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if isinstance(key, str):
|
if isinstance(key, str):
|
||||||
return [getattr(x, key) for x in self._data]
|
return [getattr(x, key) for x in self._data]
|
||||||
|
|||||||
26
data/p-english-1gram.txt
Normal file
26
data/p-english-1gram.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
E 312958
|
||||||
|
T 224480
|
||||||
|
A 204391
|
||||||
|
O 191450
|
||||||
|
N 183099
|
||||||
|
I 172625
|
||||||
|
H 166494
|
||||||
|
S 162111
|
||||||
|
R 146878
|
||||||
|
D 117728
|
||||||
|
L 96025
|
||||||
|
U 64904
|
||||||
|
M 61280
|
||||||
|
C 60649
|
||||||
|
W 58914
|
||||||
|
F 54486
|
||||||
|
G 50900
|
||||||
|
Y 45928
|
||||||
|
P 44708
|
||||||
|
B 34375
|
||||||
|
V 26784
|
||||||
|
K 20277
|
||||||
|
X 4031
|
||||||
|
J 2485
|
||||||
|
Z 2385
|
||||||
|
Q 2318
|
||||||
613
data/p-english-2gram.txt
Normal file
613
data/p-english-2gram.txt
Normal file
@@ -0,0 +1,613 @@
|
|||||||
|
TH 79029
|
||||||
|
HE 75275
|
||||||
|
IN 48279
|
||||||
|
ER 47692
|
||||||
|
AN 45882
|
||||||
|
RE 36280
|
||||||
|
ND 35237
|
||||||
|
ED 32672
|
||||||
|
HA 30003
|
||||||
|
ES 29852
|
||||||
|
TO 28997
|
||||||
|
AT 28979
|
||||||
|
EN 28866
|
||||||
|
ON 28006
|
||||||
|
HI 26651
|
||||||
|
NT 25682
|
||||||
|
NG 25415
|
||||||
|
EA 25382
|
||||||
|
ST 24669
|
||||||
|
OU 23663
|
||||||
|
AS 23081
|
||||||
|
IS 22421
|
||||||
|
IT 21671
|
||||||
|
OR 20401
|
||||||
|
TE 19640
|
||||||
|
SE 19055
|
||||||
|
ET 18790
|
||||||
|
AR 18468
|
||||||
|
TI 18397
|
||||||
|
OF 17491
|
||||||
|
SA 17488
|
||||||
|
LE 17322
|
||||||
|
RO 16542
|
||||||
|
NE 15719
|
||||||
|
NO 15497
|
||||||
|
ME 15276
|
||||||
|
SH 15204
|
||||||
|
TA 15107
|
||||||
|
AL 15006
|
||||||
|
RI 14997
|
||||||
|
DE 14954
|
||||||
|
OT 14666
|
||||||
|
VE 14563
|
||||||
|
SS 14466
|
||||||
|
HO 14410
|
||||||
|
TT 14205
|
||||||
|
DT 13993
|
||||||
|
SO 13891
|
||||||
|
LL 13446
|
||||||
|
EL 13408
|
||||||
|
SI 13382
|
||||||
|
WA 13111
|
||||||
|
CE 13086
|
||||||
|
CO 12754
|
||||||
|
WH 12724
|
||||||
|
RA 12445
|
||||||
|
OM 12245
|
||||||
|
EW 12128
|
||||||
|
AD 12098
|
||||||
|
DI 11870
|
||||||
|
EC 11708
|
||||||
|
MA 11502
|
||||||
|
DA 11471
|
||||||
|
NA 11388
|
||||||
|
EM 11361
|
||||||
|
OW 11305
|
||||||
|
BE 11272
|
||||||
|
CH 11207
|
||||||
|
UT 11197
|
||||||
|
EE 11030
|
||||||
|
RS 10816
|
||||||
|
WI 10610
|
||||||
|
NC 10249
|
||||||
|
LY 10231
|
||||||
|
LI 10189
|
||||||
|
IM 10111
|
||||||
|
US 9279
|
||||||
|
RT 9247
|
||||||
|
LO 9133
|
||||||
|
LA 9094
|
||||||
|
ID 9076
|
||||||
|
DO 9043
|
||||||
|
AI 9024
|
||||||
|
EH 8926
|
||||||
|
OS 8918
|
||||||
|
NS 8915
|
||||||
|
UN 8763
|
||||||
|
IC 8754
|
||||||
|
FO 8610
|
||||||
|
IL 8600
|
||||||
|
OL 8592
|
||||||
|
NI 8564
|
||||||
|
EO 8510
|
||||||
|
EI 8479
|
||||||
|
IE 8479
|
||||||
|
PE 8450
|
||||||
|
EF 8438
|
||||||
|
TS 8415
|
||||||
|
FT 8260
|
||||||
|
UR 8177
|
||||||
|
GH 8172
|
||||||
|
OO 8138
|
||||||
|
AC 8137
|
||||||
|
WE 7858
|
||||||
|
EP 7796
|
||||||
|
YO 7773
|
||||||
|
PR 7763
|
||||||
|
DH 7502
|
||||||
|
DS 7442
|
||||||
|
IO 7427
|
||||||
|
MO 7391
|
||||||
|
LD 7275
|
||||||
|
OV 6989
|
||||||
|
TR 6829
|
||||||
|
HT 6805
|
||||||
|
CA 6753
|
||||||
|
EV 6675
|
||||||
|
GA 6497
|
||||||
|
UL 6423
|
||||||
|
GE 6224
|
||||||
|
RY 6102
|
||||||
|
YA 6036
|
||||||
|
FR 6026
|
||||||
|
IR 6010
|
||||||
|
FA 5897
|
||||||
|
TW 5802
|
||||||
|
MI 5797
|
||||||
|
AM 5751
|
||||||
|
KE 5714
|
||||||
|
RR 5570
|
||||||
|
FI 5536
|
||||||
|
AY 5530
|
||||||
|
SW 5517
|
||||||
|
DR 5338
|
||||||
|
PA 5284
|
||||||
|
AP 5252
|
||||||
|
BU 5243
|
||||||
|
YT 5228
|
||||||
|
SP 5162
|
||||||
|
RD 5133
|
||||||
|
EY 5073
|
||||||
|
PO 4970
|
||||||
|
WO 4933
|
||||||
|
EB 4915
|
||||||
|
FE 4890
|
||||||
|
GT 4883
|
||||||
|
VI 4864
|
||||||
|
GO 4801
|
||||||
|
AV 4758
|
||||||
|
DB 4699
|
||||||
|
SU 4480
|
||||||
|
TU 4464
|
||||||
|
EG 4446
|
||||||
|
DN 4416
|
||||||
|
SC 4406
|
||||||
|
PI 4370
|
||||||
|
IG 4337
|
||||||
|
AB 4279
|
||||||
|
PL 4230
|
||||||
|
DW 4209
|
||||||
|
TL 4190
|
||||||
|
OD 4120
|
||||||
|
AG 4110
|
||||||
|
BO 4072
|
||||||
|
RM 4046
|
||||||
|
NH 4030
|
||||||
|
OP 4015
|
||||||
|
CT 4010
|
||||||
|
SM 3982
|
||||||
|
TY 3967
|
||||||
|
LT 3862
|
||||||
|
YS 3827
|
||||||
|
IF 3814
|
||||||
|
GI 3791
|
||||||
|
MP 3741
|
||||||
|
KI 3731
|
||||||
|
OK 3714
|
||||||
|
OH 3653
|
||||||
|
BL 3612
|
||||||
|
IA 3612
|
||||||
|
IV 3450
|
||||||
|
UG 3372
|
||||||
|
OA 3359
|
||||||
|
GR 3306
|
||||||
|
FF 3293
|
||||||
|
AW 3290
|
||||||
|
BA 3233
|
||||||
|
RN 3227
|
||||||
|
RU 3227
|
||||||
|
YE 3150
|
||||||
|
DD 3122
|
||||||
|
EX 3117
|
||||||
|
RH 3098
|
||||||
|
OI 3060
|
||||||
|
SF 3058
|
||||||
|
NW 2989
|
||||||
|
SB 2969
|
||||||
|
UP 2857
|
||||||
|
YI 2820
|
||||||
|
DL 2786
|
||||||
|
NL 2777
|
||||||
|
LF 2753
|
||||||
|
SL 2729
|
||||||
|
MT 2702
|
||||||
|
AK 2690
|
||||||
|
PP 2652
|
||||||
|
DF 2625
|
||||||
|
CK 2624
|
||||||
|
MS 2618
|
||||||
|
DP 2609
|
||||||
|
AF 2608
|
||||||
|
SN 2606
|
||||||
|
MY 2603
|
||||||
|
YW 2570
|
||||||
|
CI 2567
|
||||||
|
PT 2545
|
||||||
|
AU 2545
|
||||||
|
LS 2543
|
||||||
|
BY 2530
|
||||||
|
NN 2489
|
||||||
|
RC 2478
|
||||||
|
TB 2467
|
||||||
|
SK 2432
|
||||||
|
WN 2427
|
||||||
|
OB 2423
|
||||||
|
DM 2422
|
||||||
|
NY 2411
|
||||||
|
RW 2391
|
||||||
|
OC 2375
|
||||||
|
QU 2318
|
||||||
|
YH 2249
|
||||||
|
VA 2226
|
||||||
|
UC 2219
|
||||||
|
NF 2191
|
||||||
|
KN 2170
|
||||||
|
TC 2158
|
||||||
|
FH 2143
|
||||||
|
HH 2098
|
||||||
|
CR 2070
|
||||||
|
TM 2051
|
||||||
|
RL 2024
|
||||||
|
GS 2024
|
||||||
|
CL 1998
|
||||||
|
DC 1996
|
||||||
|
FU 1985
|
||||||
|
BR 1976
|
||||||
|
TF 1941
|
||||||
|
UE 1929
|
||||||
|
DU 1907
|
||||||
|
RF 1906
|
||||||
|
UI 1871
|
||||||
|
DY 1852
|
||||||
|
SD 1834
|
||||||
|
GL 1833
|
||||||
|
UA 1819
|
||||||
|
MU 1810
|
||||||
|
RG 1727
|
||||||
|
TD 1723
|
||||||
|
HU 1708
|
||||||
|
YB 1693
|
||||||
|
CU 1683
|
||||||
|
MB 1679
|
||||||
|
NK 1671
|
||||||
|
GU 1645
|
||||||
|
MM 1643
|
||||||
|
TP 1633
|
||||||
|
RP 1619
|
||||||
|
UD 1602
|
||||||
|
LU 1580
|
||||||
|
DG 1580
|
||||||
|
UM 1572
|
||||||
|
HR 1570
|
||||||
|
SR 1570
|
||||||
|
FL 1560
|
||||||
|
RB 1559
|
||||||
|
VO 1553
|
||||||
|
OG 1513
|
||||||
|
TN 1508
|
||||||
|
NB 1508
|
||||||
|
IK 1507
|
||||||
|
YD 1441
|
||||||
|
IB 1429
|
||||||
|
KA 1424
|
||||||
|
WS 1418
|
||||||
|
YF 1408
|
||||||
|
NU 1378
|
||||||
|
GN 1372
|
||||||
|
EU 1368
|
||||||
|
XP 1362
|
||||||
|
LW 1315
|
||||||
|
YC 1311
|
||||||
|
OY 1296
|
||||||
|
NP 1285
|
||||||
|
WT 1277
|
||||||
|
KH 1268
|
||||||
|
GW 1260
|
||||||
|
HS 1230
|
||||||
|
PS 1203
|
||||||
|
JU 1183
|
||||||
|
PU 1179
|
||||||
|
KO 1176
|
||||||
|
HY 1162
|
||||||
|
NM 1162
|
||||||
|
EK 1157
|
||||||
|
LK 1149
|
||||||
|
FS 1134
|
||||||
|
MH 1092
|
||||||
|
HW 1077
|
||||||
|
CC 1076
|
||||||
|
AH 1066
|
||||||
|
SG 1065
|
||||||
|
OE 1048
|
||||||
|
BI 1024
|
||||||
|
YM 1022
|
||||||
|
RK 1015
|
||||||
|
UB 1014
|
||||||
|
KS 1004
|
||||||
|
MW 992
|
||||||
|
YP 985
|
||||||
|
RV 980
|
||||||
|
YL 966
|
||||||
|
NR 957
|
||||||
|
NV 945
|
||||||
|
FW 938
|
||||||
|
LM 935
|
||||||
|
YR 928
|
||||||
|
GB 918
|
||||||
|
LH 915
|
||||||
|
IP 902
|
||||||
|
SY 901
|
||||||
|
HM 868
|
||||||
|
GF 833
|
||||||
|
LR 833
|
||||||
|
VS 807
|
||||||
|
WW 805
|
||||||
|
LP 768
|
||||||
|
KT 753
|
||||||
|
KU 749
|
||||||
|
ZE 737
|
||||||
|
FM 737
|
||||||
|
TG 721
|
||||||
|
JO 716
|
||||||
|
LB 709
|
||||||
|
YN 705
|
||||||
|
WR 685
|
||||||
|
GG 685
|
||||||
|
DV 680
|
||||||
|
IW 668
|
||||||
|
PH 646
|
||||||
|
ZO 640
|
||||||
|
FC 636
|
||||||
|
AA 627
|
||||||
|
WD 622
|
||||||
|
GM 615
|
||||||
|
EQ 612
|
||||||
|
UZ 611
|
||||||
|
XC 610
|
||||||
|
YG 605
|
||||||
|
IZ 597
|
||||||
|
VN 595
|
||||||
|
IH 594
|
||||||
|
FB 574
|
||||||
|
FP 574
|
||||||
|
GP 570
|
||||||
|
SV 564
|
||||||
|
TK 563
|
||||||
|
LC 525
|
||||||
|
LV 521
|
||||||
|
MN 521
|
||||||
|
HC 515
|
||||||
|
XT 512
|
||||||
|
DK 501
|
||||||
|
HP 492
|
||||||
|
UK 490
|
||||||
|
BS 489
|
||||||
|
GD 484
|
||||||
|
DJ 477
|
||||||
|
GC 477
|
||||||
|
JE 477
|
||||||
|
MF 469
|
||||||
|
HB 463
|
||||||
|
VW 444
|
||||||
|
LN 441
|
||||||
|
HD 427
|
||||||
|
HF 421
|
||||||
|
KL 420
|
||||||
|
HN 414
|
||||||
|
XI 414
|
||||||
|
UW 411
|
||||||
|
KW 407
|
||||||
|
SQ 406
|
||||||
|
UF 397
|
||||||
|
FY 394
|
||||||
|
LG 391
|
||||||
|
AZ 387
|
||||||
|
HL 379
|
||||||
|
WL 374
|
||||||
|
XA 369
|
||||||
|
UH 364
|
||||||
|
II 355
|
||||||
|
FD 353
|
||||||
|
WB 346
|
||||||
|
EJ 344
|
||||||
|
PY 343
|
||||||
|
YY 329
|
||||||
|
ML 324
|
||||||
|
WF 316
|
||||||
|
XE 314
|
||||||
|
CY 312
|
||||||
|
NQ 312
|
||||||
|
WC 312
|
||||||
|
FN 303
|
||||||
|
YU 295
|
||||||
|
WM 292
|
||||||
|
VL 291
|
||||||
|
IX 290
|
||||||
|
MR 284
|
||||||
|
BT 277
|
||||||
|
FG 274
|
||||||
|
MC 271
|
||||||
|
PW 268
|
||||||
|
TV 258
|
||||||
|
VT 254
|
||||||
|
ZI 251
|
||||||
|
GY 248
|
||||||
|
VH 245
|
||||||
|
AJ 243
|
||||||
|
SJ 238
|
||||||
|
BB 236
|
||||||
|
UO 231
|
||||||
|
YK 231
|
||||||
|
MD 219
|
||||||
|
AE 216
|
||||||
|
AO 214
|
||||||
|
NJ 213
|
||||||
|
EZ 213
|
||||||
|
RX 212
|
||||||
|
HG 211
|
||||||
|
VR 211
|
||||||
|
KB 206
|
||||||
|
KY 205
|
||||||
|
KR 200
|
||||||
|
DQ 199
|
||||||
|
WY 198
|
||||||
|
PF 197
|
||||||
|
KF 194
|
||||||
|
WP 191
|
||||||
|
PC 182
|
||||||
|
CS 179
|
||||||
|
YV 176
|
||||||
|
BJ 175
|
||||||
|
IU 170
|
||||||
|
ZA 166
|
||||||
|
ZH 162
|
||||||
|
TZ 160
|
||||||
|
MG 155
|
||||||
|
PB 153
|
||||||
|
TJ 151
|
||||||
|
HK 151
|
||||||
|
KP 149
|
||||||
|
KC 149
|
||||||
|
FV 142
|
||||||
|
KM 142
|
||||||
|
OX 141
|
||||||
|
UV 136
|
||||||
|
ZU 131
|
||||||
|
VY 128
|
||||||
|
OZ 128
|
||||||
|
OJ 121
|
||||||
|
CQ 119
|
||||||
|
WG 113
|
||||||
|
YJ 109
|
||||||
|
AQ 107
|
||||||
|
FK 107
|
||||||
|
WU 104
|
||||||
|
TQ 104
|
||||||
|
GV 103
|
||||||
|
PM 100
|
||||||
|
JA 98
|
||||||
|
FJ 98
|
||||||
|
WK 94
|
||||||
|
VB 94
|
||||||
|
VC 91
|
||||||
|
XH 89
|
||||||
|
XV 87
|
||||||
|
MV 87
|
||||||
|
RZ 87
|
||||||
|
VD 86
|
||||||
|
HV 84
|
||||||
|
NX 84
|
||||||
|
KG 81
|
||||||
|
XX 79
|
||||||
|
RJ 78
|
||||||
|
VF 77
|
||||||
|
KD 76
|
||||||
|
BM 76
|
||||||
|
UY 74
|
||||||
|
RQ 72
|
||||||
|
OQ 70
|
||||||
|
ZM 66
|
||||||
|
VG 63
|
||||||
|
GJ 63
|
||||||
|
VP 61
|
||||||
|
MK 57
|
||||||
|
PN 57
|
||||||
|
YQ 56
|
||||||
|
WV 51
|
||||||
|
BV 49
|
||||||
|
GK 47
|
||||||
|
ZZ 47
|
||||||
|
ZL 47
|
||||||
|
VM 46
|
||||||
|
LQ 44
|
||||||
|
PD 43
|
||||||
|
UX 43
|
||||||
|
AX 43
|
||||||
|
IQ 43
|
||||||
|
HJ 42
|
||||||
|
GQ 40
|
||||||
|
CW 38
|
||||||
|
UU 37
|
||||||
|
XW 36
|
||||||
|
BW 36
|
||||||
|
DZ 34
|
||||||
|
CF 33
|
||||||
|
VU 32
|
||||||
|
ZD 32
|
||||||
|
VK 32
|
||||||
|
HQ 31
|
||||||
|
NZ 31
|
||||||
|
CD 30
|
||||||
|
PK 28
|
||||||
|
XO 28
|
||||||
|
CP 27
|
||||||
|
CB 27
|
||||||
|
WQ 27
|
||||||
|
LZ 27
|
||||||
|
WJ 24
|
||||||
|
LJ 24
|
||||||
|
MQ 23
|
||||||
|
MJ 23
|
||||||
|
ZN 22
|
||||||
|
KV 22
|
||||||
|
XS 22
|
||||||
|
BD 21
|
||||||
|
XU 20
|
||||||
|
SX 19
|
||||||
|
BH 18
|
||||||
|
CG 18
|
||||||
|
CM 18
|
||||||
|
XM 17
|
||||||
|
FQ 17
|
||||||
|
SZ 17
|
||||||
|
ZW 17
|
||||||
|
BN 16
|
||||||
|
IJ 15
|
||||||
|
ZY 14
|
||||||
|
IY 14
|
||||||
|
PJ 14
|
||||||
|
KQ 14
|
||||||
|
YZ 14
|
||||||
|
XF 14
|
||||||
|
ZT 13
|
||||||
|
PG 13
|
||||||
|
UJ 12
|
||||||
|
KK 12
|
||||||
|
JI 11
|
||||||
|
XR 11
|
||||||
|
XY 11
|
||||||
|
BC 10
|
||||||
|
KJ 10
|
||||||
|
XL 10
|
||||||
|
PQ 9
|
||||||
|
PV 9
|
||||||
|
GZ 9
|
||||||
|
ZS 8
|
||||||
|
VJ 8
|
||||||
|
VV 8
|
||||||
|
XB 8
|
||||||
|
XN 8
|
||||||
|
HZ 7
|
||||||
|
ZB 7
|
||||||
|
CZ 6
|
||||||
|
CV 6
|
||||||
|
CN 6
|
||||||
|
FZ 5
|
||||||
|
ZF 5
|
||||||
|
ZV 4
|
||||||
|
UQ 4
|
||||||
|
XQ 4
|
||||||
|
BF 4
|
||||||
|
ZC 4
|
||||||
|
ZK 4
|
||||||
|
ZP 3
|
||||||
|
ZR 3
|
||||||
|
VQ 3
|
||||||
|
BP 3
|
||||||
|
CJ 2
|
||||||
|
WZ 2
|
||||||
|
XG 2
|
||||||
|
BG 2
|
||||||
|
XD 2
|
||||||
|
VZ 1
|
||||||
|
MZ 1
|
||||||
|
BQ 1
|
||||||
|
ZQ 1
|
||||||
|
XJ 1
|
||||||
|
KZ 1
|
||||||
|
XK 1
|
||||||
|
ZG 1
|
||||||
|
YX 1
|
||||||
|
VX 1
|
||||||
|
DX 1
|
||||||
8108
data/p-english-3gram.txt
Normal file
8108
data/p-english-3gram.txt
Normal file
File diff suppressed because it is too large
Load Diff
59919
data/p-english-4gram.txt
Normal file
59919
data/p-english-4gram.txt
Normal file
File diff suppressed because it is too large
Load Diff
229815
data/p-english-5gram.txt
Normal file
229815
data/p-english-5gram.txt
Normal file
File diff suppressed because it is too large
Load Diff
11
lib.py
11
lib.py
@@ -99,6 +99,17 @@ def affine_decrypt(x, key, n=29): # key: (s, t)
|
|||||||
return ((x - key[1]) * affine_inverse(key[0], n)) % n
|
return ((x - key[1]) * affine_inverse(key[0], n)) % n
|
||||||
|
|
||||||
|
|
||||||
|
def autokey_reverse(data, keylen, pos, search_term):
|
||||||
|
ret = [29] * keylen
|
||||||
|
for o in range(len(search_term)):
|
||||||
|
plain = search_term[o]
|
||||||
|
i = pos + o
|
||||||
|
while i >= 0:
|
||||||
|
plain = (data[i] - plain) % 29
|
||||||
|
i -= keylen
|
||||||
|
ret[i + keylen] = plain
|
||||||
|
return ret
|
||||||
|
|
||||||
# alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
# alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
# cipher = 'YDIDWYASDDJVAPJMMBIASDTJVAMD'
|
# cipher = 'YDIDWYASDDJVAPJMMBIASDTJVAMD'
|
||||||
# indices = [affine_decrypt(alphabet.index(x), (5, 9), 26) for x in cipher]
|
# indices = [affine_decrypt(alphabet.index(x), (5, 9), 26) for x in cipher]
|
||||||
|
|||||||
Reference in New Issue
Block a user