0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A trie-based anagram solver.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0
 Project Readme

RubyAnagrams

RubyAnagrams is a simple anagram solver built with a trie prefix tree.

Usage

Require the Gem:

require 'ruby-anagrams'

Creating a new trie

Creating an empty trie:

root = RubyAnagrams::Root.new

Creating a trie filled with strings from a text file:

root = RubyAnagrams::Root.new "some_text_file.txt"

Adding strings

root << "mystring"

You can also use #add

Testing for string inclusion

root.include? "mystring"   #=> true
root.include? "skldflsjd"  #=> false

You can also use #contains?

Finding anagrams

root.anagrams "pale" #=> ["leap", "pale", "peal" "plea"]

Including partial anagrams:

  root.anagrams "pale", partial: true #=> ["ae", "al", "ale", "alp", "ape", "el", "la", "lap", "lea", "leap", "pa", "pal", "pale", "pe", "pea", "peal", "plea"]

"*" wildcards:

root.anagrams "b*n" #=> ["ban", "ben", "bin", "bun", "nab", "neb", "nib", "nob", "nub"]