Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Named Number Lists

named_number_lists.livemd

Named Number Lists

Mix.install([
  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}
])

Navigation

Home Report An Issue FizzBuzzMeasurements

Named Number Lists

Generate a list with ten random integers from 0 to 9. Convert each integer in this list to its string representation so 1 would become "one".

# Input
[1, 2, 4, 2, 7, 8, 0, 4, 5, 6]
# Output
["one", "two", "four", "two", "seven", "eight", "zero", "four", "five", "six"]
flowchart
   0 --> zero
   1 --> one
   2 --> two
   3 --> three
   4 --> four
   5 --> five
   6 --> six
   7 --> seven
   8 --> eight
   9 --> nine

Example Solution

  random_integers = Enum.map(1..10, fn _ -> Enum.random(0..9) end)

  Enum.map(random_integers, fn integer ->
    case integer do
      0 -> "zero"
      1 -> "one"
      2 -> "two"
      3 -> "three"
      4 -> "four"
      5 -> "five"
      6 -> "six"
      7 -> "seven"
      8 -> "eight"
      9 -> "nine"
    end
  end)

Enter your solution below.

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish Named Number Lists exercise"
$ git push

We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.

Navigation

Home Report An Issue FizzBuzzMeasurements