StayNTouch Coding Exercises

As a candidate to our engineering team, we are offering the following exercises to allow you to showcase your development skills. The purpose of these exercises are for you to express yourself technically, outside of the in-person interview. Take as much time as you would like, but it should only take a few hours.

Submission Instructions

  1. Complete the exercises as described below.
  • Commit each solution separately with a brief explanation of your solution. Do not squash your commits.
  • Your code should be clear and well-documented.
  1. When you are done, use git bundle to bundle up the repo, compress it (zip/tar) and send it back to jongmyung@stayntouch.com. We sometimes receive corrupted bundles, so please verify your bundle.

Environment

Ruby 2.5.x, Rspec, Bundler

Exercises

Note: Feel free to use Google to look up syntax, method definitions, etc. but please don't just look up the answers. Any files you add should be added to the lib directory and required within the relevant code exercise.

Fibonacci Sequence

Implement a method that will calculate the Nth number of the Fibonacci sequence (http://en.wikipedia.org/wiki/Fibonacci_number).

Tests have been pre-written using rspec at /spec/fibonacci_spec.rb. There is a Fibonacci class in code/fibonacci.rb the solution should be implementation in the calculate method.

Hotel Parser

With the provided YAML file in data/hotel.yaml, implement the hotel parser in a way that parses the file and returns a collection of nested objects representing the data. You may use the standard YAML parser, but do not use OpenStruct. Bonus points for good OOP representation.

The object should respond to the following requirements:

  1. Using the [] operator:
data['hotels'].last['rooms'].first['amenities'].last => "Pool"
  1. Using method calls:
data.hotels.last.rooms.first.amenities.last => "Pool"

Tests have been pre-written using rspec in /spec/hotel_parser_spec.rb. There is a parse method in the HotelParser class located in code/hotel_parser.rb.

HTML Scraper

This exercise is to build a HTML screen scraper. The scraper will read provided paws.html file, navigate pagination, and collect href source for all baby female dogs on each page.

You will likely want to use an HTML parser like Nokogiri and use the listing pagination to iterate each page.

One Test has been written using rspec in /spec/puppies_spec.rb. There is a parse method in the Puppies class located in code/puppies.rb. The paws.html file is provided in the data directory.