Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.47 KB

problem_set_1_map_reduce_filter.md

File metadata and controls

43 lines (28 loc) · 1.47 KB

Map, Reduce, Filter

Lambda

In order to use map and filter you're going to have to get used to lambda functions. Create lambda functions to do the following things:

  1. Find the square of a number.
  2. Find the cube of a number.
  3. Convert a Fahrenheit temperature to Celsius. (Hint: (5/9)(F - 32))
  4. Add two numbers.
  5. Multiple two numbers.
  6. Join two strings, by placing the space character between them.

Map

Using only a single line map statement, create a list of the following items:

  1. The cubes of the numbers 1 through 33.
  2. All numbers less than 1000 that are evenly divisible by 3.
  3. Convert these temps from Fahrenheit to Celsuis: temps = [-42.0, -10.9, 0.0, 20.7, 32.0, 42.0, 101, 273, 320]
  4. The square of all even, two-digit numbers.

Filter

Using only a single filter statement, solve the following puzzles:

  1. What positive, odd numbers less than 1000 are evenly divisible by 7 and 13?
  2. What integers less than 10,000 are both: the square of another integer and evenly divisible by 2?
  3. How many positive, even numbers less than 1,000,000 are evenly divisible by 99?

Choose Your Own Adventure

Use map and/or filter (and maybe sum) to solve the following puzzles:

  1. Find all the numbers evenly divisible by 3, below 100.
  2. Calculate the sum of all the even numbers from 2 to 222.
  3. Calculate the sum of the first five powers of seven.

Solutions

Back to Lecture