This article was previously published on codementor.io
The Ruby language was developed by Yukihiro Matsumoto (“Matz”) in 1995. The language was designed to be object-oriented, intuitive, and easy to learn to optimize for developer time. As “Matz” once said:
“…in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.”
In this tutorial, we’ll explore Ruby best practices to ensure our code is in line with Matz’s principles of being legible, modular, and concise.
Let’s say we are writing a program…
In this tutorial, we will explore the naive and optimized solutions for a simple interview-type problem.
Given an array (arr) of n unique non-negative integers, return a non-negative integer that is not in the array. Return nil if the array contains all possible integers.
In this solution we search the array for integer n, and return n if it is not in the array. We iterate through every integer from zero to the maximum integer in array + 1 to capture all possible integers that might not be in the array. See below.
In this solution we search through…
In this tutorial, we’ll cover two different algorithms to encrypt text with Vignere’s Cipher. One is a more naive but concise solution and the second is more computationally efficient. We’ll discuss the time and space complexity of each and conclude with how to design your code so it is as efficient as it can be.
Vignere’s Cipher is a variation on the more well known Caesar’s cipher. Before diving into Vignere its important to understand how Caesar’s cipher works.
Caesar’s cipher takes a single integer key, and offsets each character in the target string by that many letters in the…
This tutorial will take you through the steps to make your own Rock, Paper, Scissors command line game. Before you begin, you should be fairly comfortable with object oriented programming in Ruby. By the end you will have your own Ruby Gem that can be downloaded by anyone anywhere. Make a gem and get your code out there!
What is a gem? A gem is just a library of Ruby code hosted on rubygems.org that can be downloaded and used by anyone. Let’s begin!
Software Engineer, GIS Analyst