larzstr
Classic string algorithms.
The little string problems every coder meets while learning - is it a palindrome? an anagram? how different are two words? - done correctly, tested, and ready to read. A study companion: reimplement them yourself, then check against a clean reference.
larzscript pkg install str
What you get
- Palindrome, anagram, reverse
- Edit distance (Levenshtein) + similarity
- Char & word frequency
- Caesar cipher encode/decode
Try it
import "str" as str_
print(str_.is_palindrome("A man a plan a canal Panama"))
print(str_.is_anagram("listen", "silent"))
print(str_.edit_distance("kitten", "sitting"))
print(str_.char_frequency("banana"))
let enc = str_.caesar_encode("attack at dawn", 3)
print(enc, str_.caesar_decode(enc, 3))Output
true
true
3
{b: 1, a: 3, n: 2}
dwwdfn dw gdzq attack at dawnWhy it's in the Larz Stack
larzstr is a real Larzscript package (larzscript pkg install str) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.