https://github.com/abongsjoel/sub-strings
This project implements a #substrings method that takes a word and an array of valid substrings as arguments and returns a hash listing each substring that was found.
https://github.com/abongsjoel/sub-strings
ruby
Last synced: about 1 year ago
JSON representation
This project implements a #substrings method that takes a word and an array of valid substrings as arguments and returns a hash listing each substring that was found.
- Host: GitHub
- URL: https://github.com/abongsjoel/sub-strings
- Owner: abongsjoel
- License: mit
- Created: 2021-01-25T17:20:33.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-26T13:51:57.000Z (over 5 years ago)
- Last Synced: 2025-03-25T10:37:42.328Z (about 1 year ago)
- Topics: ruby
- Language: Ruby
- Homepage: https://repl.it/@abongsjoel/substrings#main.rb
- Size: 5.86 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sub Strings
> In this project, I implemented a simple #substrings method
The #substrings method takes a word as the first argument and then an array of valid substrings (our dictionary) as the second argument. It then returns a hash listing each substring (case insensitive) that was found in the original string and how many times it was found.
E.g.
```
> dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
=> ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
> substrings("below", dictionary)
=> { "below" => 1, "low" => 1 }
```
The method can also handle multiple words.
E.g.
```
> substrings("Howdy partner, sit down! How's it going?", dictionary)
=> { "down" => 1, "go" => 1, "going" => 1, "how" => 2, "howdy" => 1, "it" => 2, "i" => 3, "own" => 1, "part" => 1, "partner" => 1, "sit" => 1 }
```
## Built With
- Ruby
## Live Demo
[Repl.it Link](https://repl.it/@abongsjoel/substrings#main.rb)
## Author
👤 **Chi A. Joel**
- GitHub: [@abongsjoel](https://github.com/abongsjoel)
- Twitter: [@thierryjoel10](https://twitter.com/ThierryJoel10)
- LinkedIn: [Chi Abongwa Joel](https://www.linkedin.com/in/chi-abongwa-joel-b4285a97/)
## Acknowledgments
- [The Odin Project](https://www.theodinproject.com)
## Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check the [issues page](https://github.com/abongsjoel/sub-strings/issues).
## Show your support
Give a ⭐️ if you like this project!
## License
This project is MIT licensed.