Travis build: 429
This commit is contained in:
@ -890,14 +890,14 @@
|
|||||||
"type": "snippetListing",
|
"type": "snippetListing",
|
||||||
"title": "is_anagram",
|
"title": "is_anagram",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `s.replace()` to remove spaces from both strings.\nCompare the lengths of the two strings, return `False` if they are not equal.\nUse `sorted()` on both strings and compare the results.\n\n",
|
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `isalnum()` to filter out non-alphanumeric characters, `lower()` to transform each character to lowercase.\nUse `collections.Counter` to count the resulting characters for each string and compare the results.\n\n",
|
||||||
"tags": [
|
"tags": [
|
||||||
"string",
|
"string",
|
||||||
"intermediate"
|
"intermediate"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"hash": "efdcecce589a3812218ede260f156888eb8544ccf85eab35d1885689668292e8"
|
"hash": "15833b3a98e905cf4cbac346028c5e6b5560d3b968800b94548e77a77098b7cc"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1413,10 +1413,10 @@
|
|||||||
"type": "snippet",
|
"type": "snippet",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"fileName": "is_anagram.md",
|
"fileName": "is_anagram.md",
|
||||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `s.replace()` to remove spaces from both strings.\nCompare the lengths of the two strings, return `False` if they are not equal.\nUse `sorted()` on both strings and compare the results.\n\n",
|
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `isalnum()` to filter out non-alphanumeric characters, `lower()` to transform each character to lowercase.\nUse `collections.Counter` to count the resulting characters for each string and compare the results.\n\n",
|
||||||
"codeBlocks": {
|
"codeBlocks": {
|
||||||
"code": "def is_anagram(s1, s2):\n _str1, _str2 = s1.replace(\" \", \"\"), s2.replace(\" \", \"\")\n return False if len(_str1) != len(_str2) else sorted(_str1.lower()) == sorted(_str2.lower())",
|
"code": "from collections import Counter\n\ndef is_anagram(s1, s2):\n return Counter(\n c.lower() for c in s1 if c.isalnum()\n ) == Counter(\n c.lower() for c in s2 if c.isalnum()\n )",
|
||||||
"example": "is_anagram(\"anagram\", \"Nag a ram\") # True"
|
"example": "is_anagram(\"#anagram\", \"Nag a ram!\") # True"
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
"string",
|
"string",
|
||||||
@ -1424,11 +1424,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"hash": "efdcecce589a3812218ede260f156888eb8544ccf85eab35d1885689668292e8",
|
"hash": "15833b3a98e905cf4cbac346028c5e6b5560d3b968800b94548e77a77098b7cc",
|
||||||
"firstSeen": "1538389049",
|
"firstSeen": "1538389049",
|
||||||
"lastUpdated": "1578049045",
|
"lastUpdated": "1584622237",
|
||||||
"updateCount": 8,
|
"updateCount": 10,
|
||||||
"authorCount": 4
|
"authorCount": 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user