Sublist
Mix.install([
{:kino, github: "livebook-dev/kino", override: true},
{:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
{:vega_lite, "~> 0.1.4"},
{:kino_vega_lite, "~> 0.1.1"},
{:benchee, "~> 0.1"},
{:ecto, "~> 3.7"},
{:math, "~> 0.7.0"},
{:faker, "~> 0.17.0"},
{:utils, path: "#{__DIR__}/../utils"},
{:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])
Navigation
Sublist
We are given a list of numbers and we need to return all consecutive sublists of a given size.
iex(1)> list = [1, 1, 2, 3, 1, 4, 2]
[1, 1, 2, 3, 1, 4, 2]
iex(2)> Sublists.sublists(list, 3)
[[1, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 4], [1, 4, 2]]
Implementation
defmodule Sublist do
def sublists(list, size) do
list
end
end
Utils.feedback(:sublist, Sublist)
Commit Your Progress
Run the following in your command line from the project folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish sublist exercise"