I need to punch()
out specific characters out of a string based on an index template (mask?).
For example, I need to punch out all the characters where there is a 1
str = abcdefg
mask = 0011001
// len(str) = len(mask) always
print(punch(str, mask)) //Ouput: cdg
Essentially I need to print all the non empty subsequences of a given string:
Input: abcd
Output: a, b, c, d, ab, ac, ad, bc, bd, cd, abc, abd, acd, bcd, abcd
I am trying to implement this using brute force so I would generate all the templates for the length of input string and using the punch()
to "punch" out those subsequences.
PS: This may be a bad way to solve this prob, but I think punch()
a nifty method to have.