Skip to content

Commit 787cfaa

Browse files
authored
fix [Improve Practice Exercise] Atbash Cipher exercism#386 (exercism#403)
1 parent ef5dce3 commit 787cfaa

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

exercises/practice/atbash-cipher/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"canweriotnow"
44
],
55
"contributors": [
6-
"vermiculus"
6+
"vermiculus",
7+
"kmarker1101"
78
],
89
"files": {
910
"solution": [

exercises/practice/atbash-cipher/.meta/example.el

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"Encode PLAINTEXT to atbash-cipher encoding."
1313
(to-string (group (to-cipher-seq plaintext))))
1414

15+
(defun decode (ciphertext)
16+
"Decode CIPHERTEXT from atbash-cipher encoding."
17+
(to-string (cleanup-ciphered-seq (cl-map 'list #'encipher ciphertext))))
18+
1519
(defun to-string (seq)
1620
"Convert SEQ of characters to a string."
1721
(cl-concatenate 'string seq))

exercises/practice/atbash-cipher/atbash-cipher-test.el

+28-8
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,57 @@
77
(require 'cl-lib)
88

99
(load-file "atbash-cipher.el")
10+
1011
(declare-function encode "atbash-cipher.el" (plaintext))
12+
(declare-function decode "atbash-cipher.el" (plaintext))
1113

1214
(ert-deftest encode-no ()
13-
(should (equal "ml" (encode "no"))))
15+
(should (string= "ml" (encode "no"))))
1416

1517
(ert-deftest encode-yes ()
16-
(should (equal "bvh" (encode "yes"))))
18+
(should (string= "bvh" (encode "yes"))))
1719

1820
(ert-deftest encode-OMG ()
19-
(should (equal "lnt" (encode "OMG"))))
21+
(should (string= "lnt" (encode "OMG"))))
2022

2123
(ert-deftest encode-O-M-G ()
22-
(should (equal "lnt" (encode "O M G"))))
24+
(should (string= "lnt" (encode "O M G"))))
2325

2426
(ert-deftest encode-long-word ()
25-
(should (equal "nrmwy oldrm tob"
27+
(should (string= "nrmwy oldrm tob"
2628
(encode "mindblowingly"))))
2729

2830
(ert-deftest encode-numbers ()
29-
(should (equal "gvhgr mt123 gvhgr mt"
31+
(should (string= "gvhgr mt123 gvhgr mt"
3032
(encode "Testing, 1 2 3, testing."))))
3133

3234
(ert-deftest encode-sentence ()
33-
(should (equal "gifgs rhurx grlm"
35+
(should (string= "gifgs rhurx grlm"
3436
(encode "Truth is fiction."))))
3537

3638
(ert-deftest encode-all-the-things ()
3739
(let ((plaintext "The quick brown fox jumps over the lazy dog.")
3840
(ciphertext "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"))
39-
(should (equal ciphertext
41+
(should (string= ciphertext
4042
(encode plaintext)))))
4143

44+
(ert-deftest decode-exercism ()
45+
(should (string= "exercism" (decode "vcvix rhn"))))
46+
47+
(ert-deftest decode-a-sentence ()
48+
(should (string= "anobstacleisoftenasteppingstone" (decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v"))))
49+
50+
(ert-deftest decode-numbers ()
51+
(should (string= "testing123testing" (decode "gvhgr mt123 gvhgr mt"))))
52+
53+
(ert-deftest decode-all-the-letters ()
54+
(should (string= "thequickbrownfoxjumpsoverthelazydog" (decode "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"))))
55+
56+
(ert-deftest decode-with-two-many-spaces ()
57+
(should (string= "exercism" (decode "vc vix r hn"))))
58+
59+
(ert-deftest decode-with-no-spaces ()
60+
(should (string= "anobstacleisoftenasteppingstone" (decode "zmlyhgzxovrhlugvmzhgvkkrmthglmv"))))
61+
4262
(provide 'atbash-cipher-test)
4363
;;; atbash-cipher-test.el ends here

exercises/practice/atbash-cipher/atbash-cipher.el

+6
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
;;; Code:
88
)
99

10+
(defun decode (plaintext)
11+
"Decode atbash-cipher encoding to PLAINTEXT."
12+
;;; Code:
13+
)
14+
15+
1016
(provide 'atbash-cipher)
1117
;;; atbash-cipher.el ends here

0 commit comments

Comments
 (0)