Sha256: a5aede8be340f73e464088b805a3cf0d1ad87c76143eae43e6008fb8b47a9e2f

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

Write a function to determine if a list is a sublist of another list.

Write a function that given two lists determines if the first list is
contained within the second list, if the second list is contained within
the first list, if both lists are contained within each other or if none
of these are true.

Specifically, a list A is a sublist of list B if by dropping 0 or more elements
from the front of B and 0 or more elements from the back of B you get a list
that's completely equal to A.

Examples:

 * A = [1, 2, 3], B = [1, 2, 3, 4, 5], A is a sublist of B
 * A = [3, 4, 5], B = [1, 2, 3, 4, 5], A is a sublist of B
 * A = [3, 4], B = [1, 2, 3, 4, 5], A is a sublist of B
 * A = [1, 2, 3], B = [1, 2, 3], A is equal to B
 * A = [1, 2, 3, 4, 5], B = [2, 3, 4], A is a superlist of B
 * A = [1, 2, 4], B = [1, 2, 3, 4, 5], A is not a superlist of, sublist of or equal to B

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trackler-2.1.0.24 common/exercises/sublist/description.md
trackler-2.1.0.23 common/exercises/sublist/description.md
trackler-2.1.0.22 common/exercises/sublist/description.md
trackler-2.1.0.21 common/exercises/sublist/description.md
trackler-2.1.0.20 common/exercises/sublist/description.md
trackler-2.1.0.19 common/exercises/sublist/description.md