Skip to content

Commit cdd2bcd

Browse files
committed
Make anagram order-independent
1 parent 19df369 commit cdd2bcd

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

exercises/practice/anagram/anagram-test.rkt

+21-13
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
'())
1717

1818
(test-equal? "detects two anagrams"
19-
(anagrams-for "solemn"
20-
'("lemons" "cherry" "melons"))
19+
(sort (anagrams-for "solemn"
20+
'("lemons" "cherry" "melons"))
21+
string<?)
2122
'("lemons" "melons"))
2223

2324
(test-equal? "does not detect anagram subsets"
@@ -31,13 +32,21 @@
3132
'("inlets"))
3233

3334
(test-equal? "detects three anagrams"
34-
(anagrams-for "allergy"
35-
'("gallery" "ballerina" "regally" "clergy" "largely" "leading"))
35+
(sort (anagrams-for "allergy"
36+
'("gallery"
37+
"ballerina"
38+
"regally"
39+
"clergy"
40+
"largely"
41+
"leading"))
42+
string<?)
43+
3644
'("gallery" "regally" "largely"))
3745

3846
(test-equal? "detects multiple anagrams with different case"
39-
(anagrams-for "nose"
40-
'("Eons" "ONES"))
47+
(sort (anagrams-for "nose"
48+
'("Eons" "ONES"))
49+
string<?)
4150
'("Eons" "ONES"))
4251

4352
(test-equal? "does not detect non-anagrams with identical checksum"
@@ -50,12 +59,12 @@
5059
'("cashregister" "Carthorse" "radishes"))
5160
'("Carthorse"))
5261

53-
(test-equal? "detects anagrams using case-insensitive subject"
62+
(test-equal? "detects anagrams using case-insensitive subject"
5463
(anagrams-for "Orchestra"
5564
'("cashregister" "carthorse" "radishes"))
5665
'("carthorse"))
5766

58-
(test-equal? "detects anagrams using case-insensitive possible matches"
67+
(test-equal? "detects anagrams using case-insensitive possible matches"
5968
(anagrams-for "orchestra"
6069
'("cashregister" "Carthorse" "radishes"))
6170
'("Carthorse"))
@@ -65,27 +74,26 @@
6574
'("goGoGO"))
6675
'())
6776

68-
(test-equal? "anagrams must use all letters exactly once"
77+
(test-equal? "anagrams must use all letters exactly once"
6978
(anagrams-for "tapper"
7079
'("patter"))
7180
'())
7281

73-
(test-equal? "words are not anagrams of themselves"
82+
(test-equal? "words are not anagrams of themselves"
7483
(anagrams-for "BANANA"
7584
'("BANANA"))
7685
'())
7786

78-
(test-equal? "words are not anagrams of themselves even if letter case is partially different"
87+
(test-equal? "words are not anagrams of themselves even if letter case is partially different"
7988
(anagrams-for "BANANA"
8089
'("Banana"))
8190
'())
8291

83-
(test-equal? "words are not anagrams of themselves even if letter case is completely different"
92+
(test-equal? "words are not anagrams of themselves even if letter case is completely different"
8493
(anagrams-for "BANANA"
8594
'("banana"))
8695
'())
8796

88-
8997
(test-equal? "words other than themselves can be anagrams"
9098
(anagrams-for "LISTEN"
9199
'("LISTEN" "Silent"))

0 commit comments

Comments
 (0)