https://github.com/lucas4tech/ruby-sub-strings-example
Build a method that takes a word as the first argument and then an array of valid substrings your dictionary as the second argument using Ruby 🎯
https://github.com/lucas4tech/ruby-sub-strings-example
challenge design-patterns hackathon ruby
Last synced: 10 months ago
JSON representation
Build a method that takes a word as the first argument and then an array of valid substrings your dictionary as the second argument using Ruby 🎯
- Host: GitHub
- URL: https://github.com/lucas4tech/ruby-sub-strings-example
- Owner: lucas4tech
- Created: 2023-03-04T18:52:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T18:52:45.000Z (over 3 years ago)
- Last Synced: 2025-07-12T05:24:36.020Z (12 months ago)
- Topics: challenge, design-patterns, hackathon, ruby
- Language: Ruby
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sub Strings
Implement a method #substrings that takes a word as the first argument and then an array of valid substrings (your dictionary) as the second argument. It should return a hash listing each substring (case insensitive) that was found in the original string and how many times it was found.
```
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 }
```
Next, make sure your method can handle multiple words:
```
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 }
```
#### Quick Tips:
* Recall how to turn strings into arrays and arrays into strings.