Skip to content

Commit 6373ab6

Browse files
authored
anagram: reimplement cases where candidates isn't a set (#1943)
Short version: The focal question of this commit: **Should determining set membership be case-insensitive?** If yes, this commit makes it so. If no, this commit should be rejected. Long version: In #1928 it was codified that the input `candidates` is a set of words. Recall that a set contains no duplicates. Recall that ever since July 2013, it has been the intent of this exercise that determining whether two words are anagram of each other should be case-insensitive: exercism/exercism@bf3e011 Recall that ever since January 2014, it has also been the intent that determining whether a word is an anagram of itself should be case-insensitive: exercism/exercism#1266 The next step is to consider the focal question of this PR: **Should determining set membership be case-insensitive?** If yes, that is consistent with the anagram relation. Then, two current cases are in violation because they contain multiple instances of the same word. These instances are the same, even despite that they have different letter case, becuse set membership is case-insensitive. If this is so, this commit rectifies, while preserving tested functionality. If no, then we are declaring that this inconsistency is acceptable because it simply means two different rules are applied in two different situations, but they are both done consistently: Set membership is case-sensitive. The anagram relation is case-insensitive. If this is so, then this PR should be closed, with the discussion serving as affirmation that the question has been duly considered. Please understand that the opinion of the author of this commit is deliberately and explicitly left unspecified. The reason for that isn't to avoid unfair influence, but instead because the author of this commit does not anticipate having an opinion on this matter either way.
1 parent 046d308 commit 6373ab6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

exercises/anagram/canonical-data.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,39 @@
152152
},
153153
"expected": []
154154
},
155+
{
156+
"uuid": "68934ed0-010b-4ef9-857a-20c9012d1ebf",
157+
"reimplements": "85757361-4535-45fd-ac0e-3810d40debc1",
158+
"description": "words are not anagrams of themselves",
159+
"property": "findAnagrams",
160+
"input": {
161+
"subject": "BANANA",
162+
"candidates": ["BANANA"]
163+
},
164+
"expected": []
165+
},
166+
{
167+
"uuid": "589384f3-4c8a-4e7d-9edc-51c3e5f0c90e",
168+
"reimplements": "85757361-4535-45fd-ac0e-3810d40debc1",
169+
"description": "words are not anagrams of themselves even if letter case is partially different",
170+
"property": "findAnagrams",
171+
"input": {
172+
"subject": "BANANA",
173+
"candidates": ["Banana"]
174+
},
175+
"expected": []
176+
},
177+
{
178+
"uuid": "ba53e423-7e02-41ee-9ae2-71f91e6d18e6",
179+
"reimplements": "85757361-4535-45fd-ac0e-3810d40debc1",
180+
"description": "words are not anagrams of themselves even if letter case is completely different",
181+
"property": "findAnagrams",
182+
"input": {
183+
"subject": "BANANA",
184+
"candidates": ["banana"]
185+
},
186+
"expected": []
187+
},
155188
{
156189
"uuid": "a0705568-628c-4b55-9798-82e4acde51ca",
157190
"description": "words other than themselves can be anagrams",
@@ -161,6 +194,17 @@
161194
"candidates": ["Listen", "Silent", "LISTEN"]
162195
},
163196
"expected": ["Silent"]
197+
},
198+
{
199+
"uuid": "33d3f67e-fbb9-49d3-a90e-0beb00861da7",
200+
"reimplements": "a0705568-628c-4b55-9798-82e4acde51ca",
201+
"description": "words other than themselves can be anagrams",
202+
"property": "findAnagrams",
203+
"input": {
204+
"subject": "LISTEN",
205+
"candidates": ["LISTEN", "Silent"]
206+
},
207+
"expected": ["Silent"]
164208
}
165209
]
166210
}

0 commit comments

Comments
 (0)