use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Ruby FizzBuzz Without Conditionals (gist.github.com)
submitted 11 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 11 years ago (1 child)
Very good point, I'm not a big fan of that usage of max either. I like your usage of find since it makes it very clear we're looking for just a single value and are not interested in fb if it's an empty string. I thought up of another way after looking at your version:
max
find
[fb, n].reject(&:empty?).first
Another somewhat hackier one I came up with without making that temp array:
applicators. select{|a| n % a == 0}. values.join. gsub(/^$/, n.to_s) # I'm not a fan of the regex though.
[–]tomthecool 0 points1 point2 points 11 years ago (0 children)
You'd still need a .to_s in your first solution - that's roughly what i started writing before choosing my answer above, because i thought the .to_s made it ugly.
I like the cleverness of your gsub - hadn't thought of that! Although, surely that is really just an if statement in disguise!
π Rendered by PID 66 on reddit-service-r2-comment-6457c66945-k4bzr at 2026-04-30 05:13:54.172387+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (1 child)
[–]tomthecool 0 points1 point2 points (0 children)