1. ## Noob array question

I have two arrays: a1 and a2. Assuming a1 is smaller than a2, how do I verify if a1 is part of a2?
For example: if a1 is [1|3|8|7] and a2 is [5|6|1|3|8|7|3|3|4], the answer to the verification will be yes because a2 contains the sequence ...1|3|8|7... which is the a1 array

2. Well if they were two arrays of characters, the answer would be strstr()

3. To solve the problem you need to understand the problem... in the tiniest steps possible.
Set yourself down and think about what has to happen, and in what order to compare the two arrays.

I'll give you a start...
The first thing you have to do is find the first character of a1 in a2 ...
But, already a complication... what happens if it's not there?

Ok... now what do you think has to happen next?

4. Originally Posted by CommonTater
To solve the problem you need to understand the problem... in the tiniest steps possible.
Set yourself down and think about what has to happen, and in what order to compare the two arrays.

I'll give you a start...
The first thing you have to do is find the first character of a1 in a2 ...
But, already a complication... what happens if it's not there?

Ok... now what do you think has to happen next?

The program is gonna end I guess

5. Originally Posted by popolianuz
The program is gonna end I guess
This discussion will, if you don't put in some effort...

6. Originally Posted by CommonTater
This discussion will, if you don't put in some effort...
If the program doesn't end then I don't know what's gonna happen because this is the only logical answer I can think of. If the first character in a1 isn't in a2, it means a1 is not part of a2, thus resulting in the ending of the program.

7. And what if it IS in there?
What should happen then?

8. If it is in there, the next a1 character got to be in there too, right after the corresponding a2 character for the previous a1 character, except if the number of remaining characters in a1 is bigger than the number of remaining characters in a2. Is this correct?

9. Think analytically... if the first character is there... now you need a test for the second character..

Is it there? What do I do next?
If it's not there... what to do next?

Do you really care at this point how many characters remain in the a2?