hw1D

4051 days ago by bobnitz

hi 
       
Traceback (click to the left of this block for traceback)
...
NameError: name 'hi' is not defined
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aGk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpLzaUpu/___code___.py", line 2, in <module>
    exec compile(u'hi
  File "", line 1, in <module>
    
NameError: name 'hi' is not defined
       
5
5
AS=AlphabeticStrings() A=AS.alphabet() 
       
print A 
       
('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')
('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')
m="ZILYPYLSNBIOMUHXBUWECHAUNNBYFYUPYMIZYPCFNBYLYCMIHYMNLCECHAUNNBYLIIN" 
       
s=m 
       
       
'ZILYPYLSNBIOMUHXBUWECHAUNNBYFYUPYMIZYPCFNBYLYCMIHYMNLCECHAUNNBYLIIN'
'ZILYPYLSNBIOMUHXBUWECHAUNNBYFYUPYMIZYPCFNBYLYCMIHYMNLCECHAUNNBYLIIN'
m=AS.encoding(s) 
       
       
ZILYPYLSNBIOMUHXBUWECHAUNNBYFYUPYMIZYPCFNBYLYCMIHYMNLCECHAUNNBYLIIN
ZILYPYLSNBIOMUHXBUWECHAUNNBYFYUPYMIZYPCFNBYLYCMIHYMNLCECHAUNNBYLIIN
CS = ShiftCryptosystem(AS) 
       
m = CS.encoding(s) 
       
c = CS.enciphering(1, m) 
       
       
AJMZQZMTOCJPNVIYCVXFDIBVOOCZGZVQZNJAZQDGOCZMZDNJIZ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NLQJDWWKHURRW
18 HQTGXGTAVJQWUCPFJCEMKPICVVJGNGCXGUQHGXKNVJGTGKUQPGUVTKMKPICVVJGTQQV
19 GPSFWFSZUIPVTBOEIBDLJOHBUUIFMFBWFTPGFWJMUIFSFJTPOFTUSJLJOHBUUIFSPPU
20 FOREVERYTHOUSANDHACKINGATTHELEAVESOFEVILTHEREISONESTRIKINGATTHEROOT
21 ENQDUDQXSGNTRZMCGZBJHMFZSSGDKDZUDRNEDUHKSGDQDHRNMDRSQHJHMFZSSGDQNNS
22 DMPCTCPWRFMSQYLBFYAIGLEYRRFCJCYTCQMDCTGJRFCPCGQMLCQRPGIGLEYRRFCPMMR
23 CLOBSBOVQELRPXKAEXZHFKDXQQEBIBXSBPLCBSFIQEBOBFPLKBPQOFHFKDXQQEBOLLQ
24 BKNARANUPDKQOWJZDWYGEJCWPPDAHAWRAOKBAREHPDANAEOKJAOPNEGEJCWPPDANKKP
25 AJMZQZMTOCJPNVIYCVXFDIBVOOCZGZVQZNJAZQDGOCZMZDNJIZNOMDFDIBVOOCZMJJO
ctext="KGIFQNHSTULBHYTLIHSLHSTITVLFQTKFQZPUUTNTSTJLBBTKLUFRTPRFKUTQTBBQTNUFNTQZTLQKFQBPVTVTLBGITPRKFBBFJLHFPQSTLJJUFTKSFVBTURDGHUFHHUTHPSFBBHGKFTBLQKXLBFQHSTZPQBHLQHJGIBGFHPRJUTLBGITSTNILKGLHTKSPXTMTIXSTQPQUYBFCHTTQYTLIBPRLNTXFHSLITJGHLHFPQRPIHLUTQHBLQKITZTFMFQNHSTSFNSTBHLZLKTVFZSPQPGIBHSTRLZGUHYZPGUKDTBHPX" 
       
ccount = ctext.character_count(); ccount 
       
{C: 1, B: 23, D: 2, G: 12, F: 24, I: 13, H: 26, K: 14, J: 7, M: 2, L:
25, N: 8, Q: 21, P: 17, S: 17, R: 8, U: 15, T: 44, V: 5, Y: 4, X: 5, Z:
8}
{C: 1, B: 23, D: 2, G: 12, F: 24, I: 13, H: 26, K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TULBHYTLIHSLHSTITVLFQTKFQZPUUTNTSTJLBBTKLUFRTPRFKUTQTBBQTNUFNTQZTLQKFQBPVTVTLBGITPRKFBBFJLHFPQSTLJJUFTKSFVBTURDGHUFHHUTHPSFBBHGKFTBLQKXLBFQHSTZPQBHLQHJGIBGFHPRJUTLBGITSTNILKGLHTKSPXTMTIXSTQPQUYBFCHTTQYTLIBPRLNTXFHSLITJGHLHFPQRPIHLUTQHBLQKITZTFMFQNHSTSFNSTBHLZLKTVFZSPQPGIBHSTRLZGUHYZPGUKDTBHPX
for w in sorted(ccount, key=ccount.get, reverse=True): print w, ccount[w] 
       
T 44
H 26
L 25
F 24
B 23
Q 21
P 17
S 17
U 15
K 14
I 13
G 12
N 8
R 8
Z 8
J 7
V 5
X 5
Y 4
D 2
M 2
C 1
T 44
H 26
L 25
F 24
B 23
Q 21
P 17
S 17
U 15
K 14
I 13
G 12
N 8
R 8
Z 8
J 7
V 5
X 5
Y 4
D 2
M 2
C 1
AS.characteristic_frequency(table_name="beker_piper") 
       
{'A': 0.0820000000000000, 'C': 0.0280000000000000, 'B':
0.0150000000000000, 'E': 0.127000000000000, 'D': 0.0430000000000000,
'G': 0.0200000000000000, 'F': 0.0220000000000000, 'I':
0.0700000000000000, 'H': 0.0610000000000000, 'K': 0.00800000000000000,
'J': 0.00200000000000000, 'M': 0.0240000000000000, 'L':
0.0400000000000000, 'O': 0.0750000000000000, 'N': 0.0670000000000000,
'Q': 0.00100000000000000, 'P': 0.0190000000000000, 'S':
0.0630000000000000, 'R': 0.0600000000000000, 'U': 0.0280000000000000,
'T': 0.0910000000000000, 'W': 0.0230000000000000, 'V':
0.0100000000000000, 'Y': 0.0200000000000000, 'X': 0.00100000000000000,
'Z': 0.00100000000000000}
{'A': 0.0820000000000000, 'C': 0.0280000000000000, 'B': 0.0150000000000000, 'E': 0.127000000000000, 'D': 0.0430000000000000, 'G': 0.0200000000000000, 'F': 0.0220000000000000, 'I': 0.0700000000000000, 'H': 0.0610000000000000, 'K': 0.00800000000000000, 'J': 0.00200000000000000, 'M': 0.0240000000000000, 'L': 0.0400000000000000, 'O': 0.0750000000000000, 'N': 0.0670000000000000, 'Q': 0.00100000000000000, 'P': 0.0190000000000000, 'S': 0.0630000000000000, 'R': 0.0600000000000000, 'U': 0.0280000000000000, 'T': 0.0910000000000000, 'W': 0.0230000000000000, 'V': 0.0100000000000000, 'Y': 0.0200000000000000, 'X': 0.00100000000000000, 'Z': 0.00100000000000000}
def digram_count(ctext): """Make dict of digrams in an alphabetic string""" ctstr = str(ctext) digrams = {} for i in range(len(ctstr)): digram = ctstr[i:i+2] if digram in digrams: count = digrams[digram] digrams[digram] = count + 1 else: digrams[digram] = 1 return(digrams) 
       
dcount=digram_count(ctext) 
       
knowns = {'A':'A'}; for w in sorted(dcount, key=dcount.get, reverse=True): print w, dcount[w] 
       
WARNING: Output truncated!  
full_output.txt



ST 10
HS 7
BH 6
FQ 6
TL 6
TQ 5
GI 5
PQ 5
UT 5
LB 5
IT 5
BB 4
LH 4
HL 4
PR 4
UF 4
KF 4
TK 4
LQ 4
TB 4
BF 3
BG 3
HP 3
ZP 3
FH 3
NT 3
SF 3
TV 3
TS 3
LI 3
TN 3
IB 3
QT 3
QH 3
QK 3
BL 2
JU 2
LK 2
JL 2
BP 2
RL 2
GU 2
TI 2
GH 2
BT 2
LZ 2
HY 2
HT 2
HU 2
HF 2
PX 2
PG 2
JG 2
ZT 2
FP 2
FT 2
FB 2
FN 2
NH 2

...

HH 1
HB 1
HG 1
PS 1
PV 1
PU 1
PI 1
ZL 1
ZG 1
KT 1
ZS 1
MF 1
UY 1
UU 1
UR 1
UL 1
UH 1
UK 1
FR 1
FV 1
FZ 1
FC 1
FJ 1
FK 1
FM 1
NI 1
NS 1
NU 1
CH 1
XL 1
XF 1
XS 1
XT 1
KD 1
KI 1
KL 1
KU 1
KX 1
DG 1
YB 1
YZ 1
DT 1
LF 1
TX 1
MT 1
TT 1
LJ 1
TH 1
TF 1
IX 1
VB 1
VF 1
VL 1
IL 1
IF 1
QS 1
QR 1
QU 1
QY 1
LN 1
WARNING: Output truncated!  
full_output.txt



ST 10
HS 7
BH 6
FQ 6
TL 6
TQ 5
GI 5
PQ 5
UT 5
LB 5
IT 5
BB 4
LH 4
HL 4
PR 4
UF 4
KF 4
TK 4
LQ 4
TB 4
BF 3
BG 3
HP 3
ZP 3
FH 3
NT 3
SF 3
TV 3
TS 3
LI 3
TN 3
IB 3
QT 3
QH 3
QK 3
BL 2
JU 2
LK 2
JL 2
BP 2
RL 2
GU 2
TI 2
GH 2
BT 2
LZ 2
HY 2
HT 2
HU 2
HF 2
PX 2
PG 2
JG 2
ZT 2
FP 2
FT 2
FB 2
FN 2
NH 2

...

HH 1
HB 1
HG 1
PS 1
PV 1
PU 1
PI 1
ZL 1
ZG 1
KT 1
ZS 1
MF 1
UY 1
UU 1
UR 1
UL 1
UH 1
UK 1
FR 1
FV 1
FZ 1
FC 1
FJ 1
FK 1
FM 1
NI 1
NS 1
NU 1
CH 1
XL 1
XF 1
XS 1
XT 1
KD 1
KI 1
KL 1
KU 1
KX 1
DG 1
YB 1
YZ 1
DT 1
LF 1
TX 1
MT 1
TT 1
LJ 1
TH 1
TF 1
IX 1
VB 1
VF 1
VL 1
IL 1
IF 1
QS 1
QR 1
QU 1
QY 1
LN 1
knowns = {'T':'E'}; 
       
def partial_decode(ctxt, known): """Partially decrypt using dict of knowns""" l = len(ctxt) pd = '-' * l for i in range(l): if ctxt[i] in known: pd = pd[:i] + known[ctxt[i]] + pd[(i+1):] return(pd) 
       
partial_decode(ctext,knowns) 
       
'-----------------------------------------------------------------------\
------------------------------------------------------------------------\
------------------------------------------------------------------------\
------------------------------------------------------------------------\
--------------'
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
knowns 
       
{'H': 'T', 'T': 'E'}
{'H': 'T', 'T': 'E'}
ctext 
       
KGIFQNHSTULBHYTLIHSLHSTITVLFQTKFQZPUUTNTSTJLBBTKLUFRTPRFKUTQTBBQTNUFNTQZ\
TLQKFQBPVTVTLBGITPRKFBBFJLHFPQSTLJJUFTKSFVBTURDGHUFHHUTHPSFBBHGKFTBLQKXL\
BFQHSTZPQBHLQHJGIBGFHPRJUTLBGITSTNILKGLHTKSPXTMTIXSTQPQUYBFCHTTQYTLIBPRL\
NTXFHSLITJGHLHFPQRPIHLUTQHBLQKITZTFMFQNHSTSFNSTBHLZLKTVFZSPQPGIBHSTRLZGU\
HYZPGUKDTBHPX
KGIFQNHSTULBHYTLIHSLHSTITVLFQTKFQZPUUTNTSTJLBBTKLUFRTPRFKUTQTBBQTNUFNTQZTLQKFQBPVTVTLBGITPRKFBBFJLHFPQSTLJJUFTKSFVBTURDGHUFHHUTHPSFBBHGKFTBLQKXLBFQHSTZPQBHLQHJGIBGFHPRJUTLBGITSTNILKGLHTKSPXTMTIXSTQPQUYBFCHTTQYTLIBPRLNTXFHSLITJGHLHFPQRPIHLUTQHBLQKITZTFMFQNHSTSFNSTBHLZLKTVFZSPQPGIBHSTRLZGUHYZPGUKDTBHPX
def trigram_count(ctext): """Make dict of digrams in an alphabetic string""" ctstr = str(ctext) trigrams = {} for i in range(len(ctstr)): trigram = ctstr[i:i+3] if trigram in trigrams: count = trigrams[trigram] trigrams[trigram] = count + 1 else: trigrams[trigram] = 1 return(trigrams) 
       
tcount=trigram_count(ctext); for w in sorted(tcount, key=tcount.get, reverse=True): print w, tcount[w] 
       
WARNING: Output truncated!  
full_output.txt



HST 5
LQK 3
BGI 2
HSL 2
LBG 2
TKS 2
LHF 2
GIT 2
TPR 2
TST 2
BLQ 2
YTL 2
TBH 2
FPQ 2
HFP 2
TLB 2
TLI 2
FBB 2
QNH 2
FQN 2
KFQ 2
NHS 2
UTQ 2
BHL 2
GIB 2
HTT 1
GHU 1
FNT 1
TIX 1
BGF 1
HBL 1
TIT 1
VTV 1
LIH 1
TQT 1
FMF 1
LQH 1
VFZ 1
TTQ 1
LUT 1
PGI 1
XTM 1
TQZ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 1
UTN 1
STI 1
STJ 1
QKI 1
KLU 1
SLH 1
HGK 1
STR 1
STS 1
ULB 1
SLI 1
TNI 1
FKU 1
STZ 1
TFM 1
RJU 1
HHU 1
BFQ 1
BHG 1
BHY 1
GUK 1
GFH 1
LZG 1
QST 1
KGI 1
CHT 1
BHS 1
UHY 1
KGL 1
knowns 
       
{'T': 'E'}
{'T': 'E'}
knowns={'H':'T','S':'H','T':'E'} for w in knowns: print w w=AS.encoding(w) print w knowns 
       
H
H
S
S
T
T
{'H': 'T', 'S': 'H', 'T': 'E'}
H
H
S
S
T
T
{'H': 'T', 'S': 'H', 'T': 'E'}
def partial_decode(ctxt, known): """Partially decrypt using dict of knowns""" l = len(ctxt) pd = '-' * l for i in range(l): for a in known: print i,a,ctxt[i] if ctxt[i] == a: print ctxt[i] pd = pd[:i] + known[ctxt[i]] + pd[(i+1):] return(pd) partial_decode(ctext,knowns) 
       
WARNING: Output truncated!  
full_output.txt



0 H K
0 S K
0 T K
1 H G
1 S G
1 T G
2 H I
2 S I
2 T I
3 H F
3 S F
3 T F
4 H Q
4 S Q
4 T Q
5 H N
5 S N
5 T N
6 H H
6 S H
6 T H
7 H S
7 S S
7 T S
8 H T
8 S T
8 T T
9 H U
9 S U
9 T U
10 H L
10 S L
10 T L
11 H B
11 S B
11 T B
12 H H
12 S H
12 T H
13 H Y
13 S Y
13 T Y
14 H T
14 S T
14 T T
15 H L
15 S L
15 T L
16 H I
16 S I
16 T I
17 H H
17 S H
17 T H
18 H S
18 S S
18 T S
19 H L
19 S L

...

281 S S
281 T S
282 H T
282 S T
282 T T
283 H R
283 S R
283 T R
284 H L
284 S L
284 T L
285 H Z
285 S Z
285 T Z
286 H G
286 S G
286 T G
287 H U
287 S U
287 T U
288 H H
288 S H
288 T H
289 H Y
289 S Y
289 T Y
290 H Z
290 S Z
290 T Z
291 H P
291 S P
291 T P
292 H G
292 S G
292 T G
293 H U
293 S U
293 T U
294 H K
294 S K
294 T K
295 H D
295 S D
295 T D
296 H T
296 S T
296 T T
297 H B
297 S B
297 T B
298 H H
298 S H
298 T H
299 H P
299 S P
299 T P
300 H X
300 S X
300 T X
'-----------------------------------------------------------------------\
------------------------------------------------------------------------\
------------------------------------------------------------------------\
------------------------------------------------------------------------\
--------------'
WARNING: Output truncated!  
full_output.txt



0 H K
0 S K
0 T K
1 H G
1 S G
1 T G
2 H I
2 S I
2 T I
3 H F
3 S F
3 T F
4 H Q
4 S Q
4 T Q
5 H N
5 S N
5 T N
6 H H
6 S H
6 T H
7 H S
7 S S
7 T S
8 H T
8 S T
8 T T
9 H U
9 S U
9 T U
10 H L
10 S L
10 T L
11 H B
11 S B
11 T B
12 H H
12 S H
12 T H
13 H Y
13 S Y
13 T Y
14 H T
14 S T
14 T T
15 H L
15 S L
15 T L
16 H I
16 S I
16 T I
17 H H
17 S H
17 T H
18 H S
18 S S
18 T S
19 H L
19 S L

...

281 S S
281 T S
282 H T
282 S T
282 T T
283 H R
283 S R
283 T R
284 H L
284 S L
284 T L
285 H Z
285 S Z
285 T Z
286 H G
286 S G
286 T G
287 H U
287 S U
287 T U
288 H H
288 S H
288 T H
289 H Y
289 S Y
289 T Y
290 H Z
290 S Z
290 T Z
291 H P
291 S P
291 T P
292 H G
292 S G
292 T G
293 H U
293 S U
293 T U
294 H K
294 S K
294 T K
295 H D
295 S D
295 T D
296 H T
296 S T
296 T T
297 H B
297 S B
297 T B
298 H H
298 S H
298 T H
299 H P
299 S P
299 T P
300 H X
300 S X
300 T X
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
 
       
Traceback (click to the left of this block for traceback)
...
ValueError: invalid literal for int() with base 10: 'H'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_124.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("cGFydGlhbF9kZWNvZGUoY3RleHQsa25vd25zKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpMuGCto/___code___.py", line 2, in <module>
    exec compile(u'partial_decode(ctext,knowns)
  File "", line 1, in <module>
    
  File "/tmp/tmpgPn5ZZ/___code___.py", line 9, in partial_decode
    print int(a),ctxt[i]
ValueError: invalid literal for int() with base 10: 'H'
if 'H' in knowns: 55 
       
55
55
knowns['S'] 
       
'H'
'H'
ctext[7] 
       
S
S
knowns[ctext[7]] 
       
Traceback (click to the left of this block for traceback)
...
KeyError: S
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_88.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("a25vd25zW2N0ZXh0WzddXQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmp3YHeFF/___code___.py", line 3, in <module>
    exec compile(u'knowns[ctext[_sage_const_7 ]]
  File "", line 1, in <module>
    
KeyError: S
def partial_decode(ctxt, known): """Partially decrypt using dict of knowns""" l = len(ctxt) pd = '-' * l for i in range(l): for a in known: print i,a,ctxt[i] if ctxt[i] == a: print ctxt[i] pd = pd[:i] + known[ctxt[i]] + pd[(i+1):] return(pd) partial_decode(ctext,knowns)