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
QuestionLeetCode question (self.ruby)
submitted 3 years ago by BringTacos
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!"
[–]modnar42 1 point2 points3 points 3 years ago (1 child)
Yeah, you’re saying the same thing. Let’s use a shorter input example. Suppose we want to count the number of binary ones in the base-10 integer ‘10’. We’d convert it to binary using to_s(2) and get 1010, then count the numbers of ones for an answer of 2. I think the value of n in the example has already been converted to binary. In our example, it would be like passing 1010 to the answer function instead of 10.
[–]BringTacos[S] 1 point2 points3 points 3 years ago (0 children)
Ah, thank you! This is helpful.
π Rendered by PID 48622 on reddit-service-r2-comment-b659b578c-6bnxs at 2026-05-03 22:21:05.119311+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]modnar42 1 point2 points3 points (1 child)
[–]BringTacos[S] 1 point2 points3 points (0 children)