Ruby Coding Exercise: Find all of the Leap Years in the 20th Century

0
1452

This Ruby coding exercise walks through how to calculate leap years in Ruby, specifically how to list out all of the leap years in the 20th century.

Summary

Find and store all of the leap years in the 20th century.

Exercise File

Code File

Exercise Description

Given an array of all of the years in the 20th century:

years = (1900..1999).to_a

Find and store all of the leap years from the 20th century and store it in an array called leap_years.

Real World Usage

Working with dates is common in Ruby development. This exercise will specifically let you compare building a date algorithm from scratch compared with leveraging the built in date library provided by Ruby.

Solution

Can be found on the solutions branch on github.

LEAVE A REPLY

Please enter your comment!
Please enter your name here