-
-
Save redsquirrel/6e4af716d36893fd5b2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I need a gem. Call it whatever you like, but when you're done with this exercise, all I want you to give me is a gem file. | |
Also, your gem should not depend on any other gems. (Depending on a testing framework like RSpec acceptable.) | |
Inside the gem, there should be 2 functions. Both functions take a string and a list of words. For example: | |
obfuscate("big string of big words is bigger", ["big", "words"]) | |
report("big string of big words is bigger", ["big", "words"]) | |
"obfuscate" returns the string with all words from the list obfuscated. For example: | |
obfuscate("big string of big words is bigger", ["big", "words"]) | |
=> "*** string of *** ***** is bigger" | |
"report" returns a hash that contains the list of words and their associated frequency in the string. For example: | |
report("big string of big words is bigger", ["big", "words"]) | |
=> {"big" => 2, "words" => 1} | |
The functions could be at the top-level or namespaced. Your call. | |
Thanks. |
As in dependencies. As in, your code shouldn't have any 'requires' at the
top. This solution should be in pure Ruby. No activesupport, etc.
…On Sun, Jun 17, 2012 at 1:55 PM, Alfonso Rush < ***@***.*** > wrote:
"...gem should not depend on any other gems"
In my rakefile...as in 'require rubygems' or as in 'development
dependencies = []'?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/6e4af716d36893fd5b2b
I'm sure I've got something more to do...but for now...https://github.com/thefonso/obfu_report
First time i've gone through this process...oh yeah...I got this thing on rubygems also...https://rubygems.org/profiles/57828
The next steps would be to:
- remove all the puts statements and return the required values (a String
for obfuscate, and a Hash for report)
- obfuscate("foo bar baz", ["bar"]) should return "foo **\* baz" rather than
"foo \* baz" which is what your code currently does
…On Mon, Jun 18, 2012 at 2:54 PM, Alfonso Rush < ***@***.*** > wrote:
I'm sure I've got something more to do...but for now...
https://github.com/thefonso/obfu_report
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/6e4af716d36893fd5b2b
Ah...more like this (version 5)?
https://rubygems.org/gems/obfu_report/versions/
https://github.com/thefonso/obfu_report
Yeah, exactly like that. Nice job.
…On Wed, Jun 20, 2012 at 9:11 AM, Alfonso Rush < ***@***.*** > wrote:
Ah...more like this (version 5)?
https://rubygems.org/gems/obfu_report/versions/
https://github.com/thefonso/obfu_report
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/6e4af716d36893fd5b2b
I didn't put this into a gem but I just wanted to take a stab at solving it.
https://gist.github.com/3764829
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"...gem should not depend on any other gems"
In my rakefile...as in 'require rubygems' or as in 'development dependencies = []'?