I'm trying to implement a function in C++(or c) that gets two inputs, one input is an array of integers value (binary values just zero or one) , the second input is an integer value one of those values: 1 , 2, 4, 8.

the function returns the correct pre-mapped pattern according to this table:

I mean by pre-mapped pattern, a pattern that it was before mapping it according to the table !.

to elaborate more, I'm giving examples: (Remap is the name of the function, we always read the given input array from left to right ..)

Code:Ramp(given array, DSSS value) - the function format. first example: Remap({0,1} , 1 ) => returns an integer array according to the table {0, 1}; (we see that 0 is mapped to value 0 , 1 is mapped to value 0 if the multiply=1) second example: Remap({1 ,1 , 0 , 0} , 2 ) => returns an integer array according to the table {1 ,0}; (we see that 11 is mapped to value 1 , 00 is mapped to value 0 if the multiply=2, so the output is {1,0}) third example: Remap({1 ,1 , 0 , 0 , 0 , 0 , 1 , 1} , 4 ) => returns an integer array according to the table {0 ,1}; (we see that 1100 is mapped to value 0 , 0011 is mapped to value 1 if the multiply=4 so output is {0,1}) third example: Remap({1 ,1 , 0 , 0 , 1 , 1, 0 , 0} , 8) => returns an integer array according to the table {0}; (we see that 11001100 is mapped to value 0 if the multiply=8 so output is {0} ) the given array is always in its rules according to the table, this means there's no case like the patterns in the given array aren't the same as the patterns on the table, for instance this array {001} with multiply 2 isn't possible .. ! In brief we are returning the pre-mapped pattern according to the attached table of mapping. (the attached table is given by default in the question itself)

My implementation code C++ is:

Code:What's wrong with my code? any help please in my implementation for the problem? honestly Im stuck on this, so it would be appreciated if there's any assistance to solve my problem or any other algorithms suggestions for my problem!Code:#include <iostream> #include <vector> std::vector<int> Remap(int* givenArray, int DSSS) { std::vector<int> ret; // result's utput switch (multiply) { case 1: { int l[2] = { 0,1 }; // for first opition in the table for (int i = 0; i < 2; i++) ret.push_back(l[i]); } break; case 2: { int l[4] = { 0 ,0 ,1 ,1 }; //for second opition in the table for (int i = 0; i < 4; i++) ret.push_back(l[i]); } break; case 4: { int l[8] = { 0 ,0,1 ,1 ,1 ,1 ,0 ,0 }; // for third opition in the table for (int i = 0; i < 8; i++) ret.push_back(l[i]); } break; case 8: { int l[16] = { 0 ,0,1,1,1,1,0,0 ,1,1,0,0,0,0,1,1 }; // for fourth opition in the table for (int i = 0; i < 16; i++) ret.push_back(l[i]); } break; } return ret; // returning the correspond pre-mapped array according to given DSSS value to the function main } int main() { int MappedPattern[4] = { 0,0,1,1 }; std::vector<int> PremappedPattern = Remap(MappedPattern, 2); // it should return {0,1} because 00 -> 0 , //11->1 according to the table over multiply =2 return 0; } ````

I was thinking to use hashtable but I don't know if it's efficient or not.

THANKS ALOT.