January 21 - Build a Multiplication Table Generator in Ruby
This coding exercise will test your ability to work with various data structures while performing mathematical calculations as you build a dynamic multiplication table generator in Ruby.
Guide Tasks
- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license
Already a Bottega Student? Sign In
Summary
Build a program that dynamically generates a hash based multiplication table in Ruby.
Exercise Description
In order to pass this exercise you'll need to build a method that returns a hash based multiplication table, where the key is the base number, and the value are the products of the key and the numbers 1 through 10.
Example
multiplication_table 3 { 1=>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2=>[2, 4, 6, 8, 10, 12, 14, 16,18, 20], 3=>[3, 6, 9, 12, 15, 18, 21, 24, 27, 30] }
Real World Usage
This exercise combines a number of key programming concepts, such as:
- Working with hashes
- Performing mathematical equations on collections of data
- Dynamically generating arrays, filling them with data, and then clearing elements
These features are common in a large number of applications. Additionally, this is a popular coding interview question.