CronDose | Daily Dev Guides

Daily Snippets for the Developer Life

2018 Book List

In the constant pursuit of learning and improving myself, I’ve discovered that going through books is a great way to expand my knowledge on a wide variety of subjects. I’m going to keep this post open and update it with each new book I read. I’ve categorized the book list into the following divisions: Faith & Spirituality Business Development & Science Skill History Fiction 2018 Book List Book List Category: Faith & Spirituality Coming soon… Book List Category: Business Coming soon… Book List Category: Development & Science Coming soon… Book List Category: Skill Coming soon… Book List Category: History […]

Find All Triplets with Zero Sum in Ruby

This is first in the series of Google coding interview questions. In order to pass this exercise, you will need to know how to find all of the potential combinations for an array, along with selecting the values that match a calculated sum. Summary Find all of the potential 3 digit combinations inside of an array that have a sum of 0. Exercise File Code File Exercise Description Given an array of numbers, return an array of arrays that contain all of the potential 3 digit combinations that have a sum of 0. Examples [0, […]

How to Sort URLs into Nested Hashes with Regular Expressions

When it comes to parsing files that contain URLs, a common practice is to have the ability to group URLs by type. In this guide we walk through how to categorize links based on regular expressions. Summary Parse multiple markdown files and group URLs by keywords. Exercise File Code File Exercise Description Inside of multiple markdown files, you will find three types of URLs: rails.devcamp.com URLs that contain the word campsite in the URL string rails.devcamp.com URLs that don’t have the word campsite in the URL string URLs that are not located on rails.devcamp.com In […]

Implementing Caching into the Rock, Paper, Scissors Game

After reviewing the Rock, Paper, Scissors game code, I realized that there was a bug with the computer guessing mechanism. In this guide we’re going to walk through how to implement caching in order to correct the issue. Summary Refactor the Rock, Paper, Scissors class by implementing caching for the computer guessing method. Exercise File Code File Exercise Description There’s currently a subtle bug with the Rock, Paper, Scissors game we built a few days ago. Work through the implementation code provided in order to see how caching can correct the issue. Real World Usage […]

How to Find All Duplicates in an Array in Ruby

Ruby has a helpful method for removing duplicates from an array, the uniq method. However, there are times when you simply want to know which elements in an array are duplicates. In this guide we’ll add a method to the Array class that returns all duplicates. Summary Build a method that returns all of the duplicates from an array in Ruby. Exercise File Code File Exercise Description Add a new method to Ruby’s Array class that returns all duplicate values. Example Input/Output ints = [1, 2, 1, 4] ints.find_duplicates # => [1] invoices = [ […]

Build Rock, Paper, Scissors in Ruby with Player vs Computer Gameplay

Rock, paper, scissors may seem like a simple game to build, however it offers a great base case for how to build a rule’s engine that can be scaled up for more complex systems. In this guide we’ll examine how to build the game so that users can play against the computer. Summary Develop a Rock, Paper, Scissors game that allows users to play against the computer. Exercise File Code File Exercise Description Build a game class that allows users to guess rock, paper, or scissors. Additionally, build a method that generates a random guess […]

Build a Dice Validator in Ruby

Building validations in programs is a common requirement. In this exercise we’ll examine how to ensure a set of dice are valid by implementing a method that returns false if the dice are outside the range of 1-6. Summary Build a dice validator program. Exercise File Code File Exercise Description Implement a program that checks to see if a roll of two dice is valid or not. Example Input/Output valid_dice? 4, 2 # => true valid_dice? 6, 6 # => true valid_dice? 5, 1 # => true valid_dice? 8, 2 # => false valid_dice? 1, […]

Build a Prefix Notation Calculator in Ruby

Building a calculator is a popular interview question and a good approach for learning a programming language. In this guide we’re going to build a Prefix Notation calculator in Ruby, which enables users to enter an operator, followed by any set of numbers to calculate. Summary Build a Prefix Notation Calculator in Ruby. Exercise File Code File Exercise Description Build a method that performs addition, subtraction, multiplication, and division on any number of values passed to the method. Additionally, ensure to handle improperly entered requests (bonus points if you build your own error handling class). […]

Pass Multiple Blocks to a Method by Leveraging Lambdas in Ruby

In many cases, lambdas are the most effective when they’re used in conjunction with methods. A method is limited to taking a single block in Ruby, however by leveraging lambdas you are able to pass in as many blocks as needed. Summary Implement a method that can accept multiple blocks by leveraging lambdas. Exercise File Code File Exercise Description Build a method that takes multiple lambdas as arguments in order to illustrate how a single method can be passed multiple blocks as arguments. Real World Usage By default, a method in Ruby is limited to […]

Demonstrate Ruby Procs / Lambdas vs Methods for Variable Scope

There are some key differences between procs / lambdas and traditional methods in Ruby, however the differences can many times be subtle. In this exercise we’ll examine how variable scope is processed differently between the different options. Summary Build a program that illustrates the differences in variable scope in Ruby between Procs / Lambdas, and traditional methods. Exercise File Code File Exercise Description Build a traditional method and a lambda or Proc and illustrate how the two processes have different access levels for local variables. Real World Usage This exercise showcases one of the subtle […]

By Daniele Zedda • 18 February

← PREV POST

By Daniele Zedda • 18 February

NEXT POST → 34
Share on