exercism/elixir/lucas-numbers/HINTS.md

1.3 KiB

Hints

General

1. Generate the base cases

2. Create the generalized case

  • Use the Stream.iterate/2 function to generate a sequence of numbers, with the next being created from the previous.
  • The starting numbers are 2 then 1, which you can pass in together using a tuple to make a pair {2, 1}
  • Make sure the next number is the sum of the two numbers previous to it.
  • To evaluate the stream to a list, use an Enum function.

3. Catch bad arguments

  • Use a guard to catch the cases when an integer isn't passed as an argument to generate/1.