commit 724c724358edb9fa9a0dc62216da76971a905541
parent 39add14edf1747fb97da9d4df190903a6f1fdad1
Author: Adam Malone <[email protected]>
Date: Fri, 16 Nov 2018 16:58:46 -0600
upgraded tests
Diffstat:
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -4,7 +4,7 @@ std::string b64lookup = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
std::string integerlookup = "0123456789";
std::string knoblookup = "abcdefghijklmnopqrstuvwxyz";
std::string inputlookup= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-std::string knobandinputlookup=knoblookup+inputlookup;
+std::string knobandinputlookup="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
bool is_digits(const std::string &str)
{
@@ -102,10 +102,13 @@ std::vector<int> parseEntireString(std::string input,std::string lookup,int type
std::vector<int> parseLookup(std::string input, int offset, std::string lookup) {
std::vector<int> absoluteSequence;
int currentVal;
+ int mappedIndex=0;
+ int length = input.length();
absoluteSequence.resize(0);
- for(unsigned int i = 0; i < input.length(); i++) {
- currentVal = lookup.find(input[i]);
+ for(unsigned int i = 0; i < length; i++) {
+ mappedIndex = (i + offset) % length;
+ currentVal = lookup.find(input[mappedIndex]);
absoluteSequence.push_back(currentVal);
}
return absoluteSequence;
@@ -166,7 +169,8 @@ std::string splitRecur(std::string input) {
std::string interleaveExpand(std::vector<std::string> blocks) {
// take a vector of strings and return a string interleave
// somewhat like bash shell expansion
- // perhaps exactly like
+ // ["a","b","cd"] --> "abcabd"
+ // ["ab","cde"] ----> "acbdaebcadbe"
std::vector<int> indices;
std::vector<int> lengths;
int outerIndex = 0;
@@ -248,3 +252,10 @@ std::string hashExpand(std::string input, int hashnum) {
}
return output;
}
+std::string concatVectorFromLookup(std::vector<int> vector, std::string lookup) {
+ std::string output="";
+ for (int i = 0; i < vector.size(); i++){
+ output+=lookup[vector[i]];
+ }
+ return output;
+}
diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp
@@ -12,6 +12,7 @@ extern std::string b64lookup;
extern std::string integerlookup;
extern std::string knoblookup;
extern std::string inputlookup;
+extern std::string knobandinputlookup;
#endif
bool is_digits(const std::string &str);
@@ -26,4 +27,5 @@ std::string splitRecur(std::string input);
std::string interleaveExpand(std::vector<std::string> blocks);
std::string hashExpand(std::string input, int hashnum);
std::string atExpand(std::string input, int atnum, std::string lookup);
-std::string countExpand(std::string input, int atnum);
-\ No newline at end of file
+std::string countExpand(std::string input, int atnum);
+std::string concatVectorFromLookup(std::vector<int> vector, std::string lookup);
diff --git a/src/test.cpp b/src/test.cpp
@@ -11,13 +11,15 @@ int main(int argc, char** argv)
}
if(type == 0) {
output = parseEntireString(argv[1],b64lookup,0);
+ printVector(output);
}
else if(type==1) {
- output = parseEntireString(argv[1],knoblookup,1);
+ output = parseEntireString(argv[1],knobandinputlookup,1);
+ printVector(output);
}
else if(type==2) {
strParens = splitRecur(argv[1]);
- printf(" splitRecur: %s\n",strParens.c_str());
+ printf("%s\n",strParens.c_str());
}
else if(type==3) {
for(int i = 0; i < argc-3; i++) {
@@ -25,7 +27,12 @@ int main(int argc, char** argv)
}
strResult = interleaveExpand(input);
}
- printVector(output);
+ else if(type==4) {
+ output = parseEntireString(argv[1],knobandinputlookup,1);
+ strResult = concatVectorFromLookup(output,knobandinputlookup);
+ printf("%s\n",strResult.c_str());
+ }
+
return 0;
}
void printVector(std::vector <int> intVector) {