@@ -17,55 +17,78 @@ def compiles():
17
17
@check50 .check (compiles )
18
18
def encrypt1 ():
19
19
"""encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key"""
20
- check50 .run ("./substitution ZYXWVUTSRQPONMLKJIHGFEDCBA" ).stdin ("A" ).stdout ("ciphertext:\s*Z\n " , "ciphertext: Z\n " ).exit (0 )
20
+ check50 .run ("./substitution ZYXWVUTSRQPONMLKJIHGFEDCBA" ).stdin ("A" ).stdout (
21
+ "ciphertext:\s*Z\n " , "ciphertext: Z\n "
22
+ ).exit (0 )
21
23
22
24
23
25
@check50 .check (compiles )
24
26
def encrypt2 ():
25
27
"""encrypts "a" as "z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key"""
26
- check50 .run ("./substitution ZYXWVUTSRQPONMLKJIHGFEDCBA" ).stdin ("a" ).stdout ("ciphertext:\s*z\n " , "ciphertext: z\n " ).exit (0 )
28
+ check50 .run ("./substitution ZYXWVUTSRQPONMLKJIHGFEDCBA" ).stdin ("a" ).stdout (
29
+ "ciphertext:\s*z\n " , "ciphertext: z\n "
30
+ ).exit (0 )
27
31
28
32
29
33
@check50 .check (compiles )
30
34
def encrypt3 ():
31
35
"""encrypts "ABC" as "NJQ" using NJQSUYBRXMOPFTHZVAWCGILKED as key"""
32
- check50 .run ("./substitution NJQSUYBRXMOPFTHZVAWCGILKED" ).stdin ("ABC" ).stdout ("ciphertext:\s*NJQ\n " , "ciphertext: NJQ\n " ).exit (0 )
36
+ check50 .run ("./substitution NJQSUYBRXMOPFTHZVAWCGILKED" ).stdin ("ABC" ).stdout (
37
+ "ciphertext:\s*NJQ\n " , "ciphertext: NJQ\n "
38
+ ).exit (0 )
33
39
34
40
35
41
@check50 .check (compiles )
36
42
def encrypt4 ():
37
43
"""encrypts "XyZ" as "KeD" using NJQSUYBRXMOPFTHZVAWCGILKED as key"""
38
- check50 .run ("./substitution NJQSUYBRXMOPFTHZVAWCGILKED" ).stdin ("XyZ" ).stdout ("ciphertext:\s*KeD\n " , "ciphertext: KeD\n " ).exit (0 )
44
+ check50 .run ("./substitution NJQSUYBRXMOPFTHZVAWCGILKED" ).stdin ("XyZ" ).stdout (
45
+ "ciphertext:\s*KeD\n " , "ciphertext: KeD\n "
46
+ ).exit (0 )
39
47
40
48
41
49
@check50 .check (compiles )
42
50
def encrypt5 ():
43
51
"""encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZTEOGXHCIPJSQD as key"""
44
- check50 .run ("./substitution YUKFRNLBAVMWZTEOGXHCIPJSQD" ).stdin ("This is CS50" ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
52
+ check50 .run ("./substitution YUKFRNLBAVMWZTEOGXHCIPJSQD" ).stdin (
53
+ "This is CS50"
54
+ ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
45
55
46
56
47
57
@check50 .check (compiles )
48
58
def encrypt6 ():
49
59
"""encrypts "This is CS50" as "Cbah ah KH50" using yukfrnlbavmwzteogxhcipjsqd as key"""
50
- check50 .run ("./substitution yukfrnlbavmwzteogxhcipjsqd" ).stdin ("This is CS50" ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
60
+ check50 .run ("./substitution yukfrnlbavmwzteogxhcipjsqd" ).stdin (
61
+ "This is CS50"
62
+ ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
51
63
52
64
53
65
@check50 .check (compiles )
54
66
def encrypt7 ():
55
67
"""encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key"""
56
- check50 .run ("./substitution YUKFRNLBAVMWZteogxhcipjsqd" ).stdin ("This is CS50" ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
68
+ check50 .run ("./substitution YUKFRNLBAVMWZteogxhcipjsqd" ).stdin (
69
+ "This is CS50"
70
+ ).stdout ("ciphertext:\s*Cbah ah KH50\n " , "ciphertext: Cbah ah KH50\n " ).exit (0 )
57
71
58
72
59
73
@check50 .check (compiles )
60
74
def encrypt8 ():
61
75
"""encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key"""
62
- check50 .run ("./substitution DWUSXNPQKEGCZFJBTLYROHIAVM" ).stdin ("The quick brown fox jumps over the lazy dog" ).stdout ("ciphertext:\s*Rqx tokug wljif nja eozby jhxl rqx cdmv sjp\n " , "ciphertext: Rqx tokug wljif nja eozby jhxl rqx cdmv sjp\n " ).exit (0 )
76
+ check50 .run ("./substitution DWUSXNPQKEGCZFJBTLYROHIAVM" ).stdin (
77
+ "The quick brown fox jumps over the lazy dog"
78
+ ).stdout (
79
+ "ciphertext:\s*Rqx tokug wljif nja eozby jhxl rqx cdmv sjp\n " ,
80
+ "ciphertext: Rqx tokug wljif nja eozby jhxl rqx cdmv sjp\n " ,
81
+ ).exit (0 )
63
82
64
83
65
84
@check50 .check (compiles )
66
85
def encrypt9 ():
67
86
"""does not encrypt non-alphabetical characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key"""
68
- check50 .run ("./substitution DWUSXNPQKEGCZFJBTLYROHIAVM" ).stdin ("Shh... Don't tell!" ).stdout ("ciphertext:\s*Yqq... Sjf'r rxcc!\n " , "ciphertext: Yqq... Sjf'r rxcc!\n " ).exit (0 )
87
+ check50 .run ("./substitution DWUSXNPQKEGCZFJBTLYROHIAVM" ).stdin (
88
+ "Shh... Don't tell!"
89
+ ).stdout (
90
+ "ciphertext:\s*Yqq... Sjf'r rxcc!\n " , "ciphertext: Yqq... Sjf'r rxcc!\n "
91
+ ).exit (0 )
69
92
70
93
71
94
@check50 .check (compiles )
@@ -108,3 +131,9 @@ def handles_duplicate_chars_lower():
108
131
def handles_multiple_duplicate_chars ():
109
132
"""handles multiple duplicate characters in key"""
110
133
check50 .run ("./substitution MMCcEFGHIJKLMNOPqRqTUVWXeZ" ).exit (1 )
134
+
135
+
136
+ @check50 .check (compiles )
137
+ def handles_single_duplicate_character ():
138
+ """handles a single mixed-case duplicate character in key"""
139
+ check50 .run ("./substitution ABCDEFGHIJKLMNOPpQRSTUVWXY" ).exit (1 )
0 commit comments