Ruby Software Engineer Interview Questions | Glassdoor

# Ruby Software Engineer Interview Questions

9

Ruby software engineer interview questions shared by candidates

## Top Interview Questions

Sort: Relevance Popular Date

Jan 27, 2012
 Describe a routine which returns the set of integers in {1..100} divisible without remainder by 3 but not by 9. 12 Answers I'm assuming the question wants us to find integers that are divisible by 3 but not by 9. This can be easily obtained using a mod function inside the following if statement: if(number % 3 == 0 && number % 9 != 0) Here is a short program I wrote in c++ to show how to solve this problem. Instead of returning the set of integer, I just printed them out on the screen: #include #include using namespace std; int main(int argc, char** argv) { int i = 0; vector list; vector::iterator it; for(i = 1; i <= 100; i++) { if(i%3 == 0 && i%9 != 0) { list.push_back(i); } } for(it = list.begin(); it != list.end(); it++) { cout << *it << endl; } return 0; } If I missed anything, please let me know. Happy coding and problem solving! That'll certainly work, Tyler, but the OP indicated he was interviewing for a Ruby On Rails - not C++ - gig. put those integers into an array, pick every third element, out of which discard every third element. Show More Responses python [x for x in range(0,100) if x % 3 == 0 and x % 9 != 0] 1) start from number = 3 Loop while(number <= 100) 2) display number 3) number = number+3, display number 4) number = number+6 Loop (1..100).map { |i| (i % 3).zero? && !(i % 9).zero? ? i : nil }.compact (1..100).select { |x| x%3 == 0 && x%9 != 0 matt has the best answer A variation on Matt's answer: (1..100).select { |n| n % 3 == 0 }.reject { |n| n % 9 == 0 } The requirement doesn't say if the input has to be a Range. If it doesn't have to be, then we don't need to traverse each element but to simply calculate it. def get_nums_by_3_not_by_9(max) arr = [] x = max.to_i / 3 x.times do |i| next if i % 3 == 0 arr << i * 3 end return arr end (1..100).select do |n| n%3 ==0 and n%9 != 0 end (1..100).to_a.delete_if{|x| !(x%3==0 && x%9>0)} or (1..100).to_a.select{|x| x%3==0 && x%9>0} or (1..100).to_a.map{|x| x%3==0 && x%9>0 ? x : nil}.compact or (1..100).to_a.reject{|x| !(x%3==0 && x%9>0)}

### Software Engineer (Ruby/Rails) at Instacart was asked...

Mar 5, 2015
 This was a pair programming session with a Ruby engineer. They allow you to use your own laptop which was great but you only get 30 minutes to finish the problem with working unit tests. I think they re-use this pair programming problem so I'm not going to divulge details here. But it wasn't a particularly hard problem, they just want you to see how you code and test. Do not forget to write unit tests! Ideally you would develop it in a TDD fashion. 2 Answers I wrote failing unit tests to determine the API first and then kept writing code until the tests succeeded. Do they expect use of rspec, minitest or just simple assert methods for tdd?

Jul 12, 2013
 Phone interview: Explain how "find_xxx" active record method works. Onsite interview: How to refactoring code (actually production code) 1 Answer ruby missing_method

Jan 27, 2012
 What do you read daily to keep up with Rails community?

### Senior Software Engineer (Ruby On Rails) at ToutApp was asked...

Feb 29, 2016
 They asked me to tell them about a set of code I had written that I was proud of. After that they asked me to describe the architecture of some code I designed and then how I would design it differently if I were to do it again and why.

### Ruby Software Engineer at TrustYou was asked...

Jan 11, 2017
 Ruby and API assignment for parsing json request for included resources 1 Answer I solved it with a recursion which I still keep the gist from it.

### Ruby Software Engineer at CrowdCompass was asked...

Jul 16, 2014
 When is it OK to release code that is not clean? 1 Answer When it's a one-off thing that will never need to be expanded, maintained, or ever used again. One-time-use (throw-away) conversion or migration scripts (as long as they are well tested with an easy fall back option) would be fine. Anything else should be thoroughly tested and clean.

### Ruby Software Engineer at CrowdCompass was asked...

Jul 16, 2014
 What is the ideal size of a properly working team

### Ruby Software Engineer at Kabam was asked...

Apr 14, 2015
 Past Projects, Use of data structures, practical problems in life of SW engineer, SQL related question
19 of 9 Interview Questions

More