In your language of choice, pick a simple ordered container of objects (arrays, list, vectors, strings,
you-name-it ...). Let C1 and C2 be two instances of this container. The goal of this exercise is to write a function that takes C1 and C2 as paramters and returns a boolean whose value is True if C1 is a
subset subsequence subword of C2 and False otherwise.
Here are some examples you could use to validate your code:
C1=(2, 39) C2=(3, 20, 2, 39, 93, 2) -> True
C1=(10, 0) C2=(5, 10, 3, 0, 9) -> False
C1=(4, 50, 3) C2=(3, 87, 4, 50) -> False
Remarks
- Most languages implement this functionality either natively (like the in operator in Python on strings) or through specialized libraries (like <string.h> in C). It goes without saying that you shouldn't use those.
- This exercise is a bit easier than the ones I usually post. It can be a good entry point for members looking to start participating in our Programming Exercises series but don't know where to start.
- If anyone feels the exercise is not challenging enough, answer the question in your weakest language (or a language you're trying to learn).