https://github.com/terror/anagram
Anagrams are cool
https://github.com/terror/anagram
Last synced: 3 months ago
JSON representation
Anagrams are cool
- Host: GitHub
- URL: https://github.com/terror/anagram
- Owner: terror
- Created: 2021-02-25T22:29:01.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-17T17:59:53.000Z (almost 5 years ago)
- Last Synced: 2025-02-06T16:54:01.277Z (11 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/anagram
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## anagram
[](https://crates.io/crates/anagram)

A collection of anagram utility functions
## Installation
You can install this crate by adding it to your Cargo.toml file
```
anagram = "0.3.0"
```
## Examples
```rust
use anagram::{count, get_next, is_anagram, occurences};
fn main() {
// count how many anagrams can be formed from a given word
let anagram_count = count("ordeals");
assert_eq!(anagram_count, 5040);
// count the number of occurences of an anagram in a given word
let occur = occurences("helloworldhello", "ll");
assert_eq!(occur, 2);
// check if a word is an anagram of another word
let ok = is_anagram("rustiscool", "oolcsistru");
assert_eq!(ok, true);
// get the next lexicographically greater anagram
let next = get_next("abcdefg");
assert_eq!(next, "abcdegf");
// get all anagrams of a word
let mut word: String = String::from("abc");
for _ in 0..count(&word) {
// get next anagram
word = get_next(&word);
println!("{}", word);
}
}
```