February 1 - Efficiently Performing Calculations on a Large Data Collection in Ruby
In this coding exercise we'll examine how lazy loading can help us perform calculations on a large data collection.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

Summary

Alter a method that maps over a large range of data so that it does not timeout.

Exercise Description

The following integer 1,000,000,000,000,000,000 crashes the method that attempts to map over it and calculate the square value of the first 5 elements. Update the method so that it can still take in the large number as an argument, but it only focuses on processing the first 5 elements. Also, you can't simply shrink the value down to 5.

Real World Usage

Working with large data sets is important for many different applications, including web apps and machine learning algorithms. This exercise specifically focuses on understanding how enumerable methods work and the difference between eager and lazy loading.

Test Cases

Code File