Last active
May 27, 2019 08:47
-
-
Save zacharysyoung/c4cbbad2af58133ddd190ea59aabcc83 to your computer and use it in GitHub Desktop.
Permutate punctuation (dots) for test email name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
Got the idea from https://learn.lytics.com/understanding/product-docs/lytics-javascript-tag/testing-and-verification#testing-audiences | |
Given an input of "test", makes: | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
This list gets exponentially big--7 letters in the name = 128 versions of the | |
name--so make sure to redirect to a file (I picked a CSV extension so | |
the list can be loaded and tracked in Excel): | |
./make_test_gmails test > test_gmails.csv | |
*/ | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
) | |
func permutatePuncs(s string, _len int, puncs []string) []string { | |
if len(s) == _len { | |
puncs = append(puncs, s) | |
return puncs | |
} | |
puncs = permutatePuncs(s+".", _len, puncs) | |
// Encode a space (" ") as a place-holder for "not-punctuated", e.g., | |
// ['.. .', '. . ', ' . .'] | |
puncs = permutatePuncs(s+" ", _len, puncs) | |
return puncs | |
} | |
func main() { | |
name := os.Args[1] | |
_len := len(name) | |
puncSets := permutatePuncs("", _len, make([]string, 0)) | |
letters := strings.Split(name, "") | |
punctuatedNames := make([]string, 0) | |
for _, puncSet := range puncSets { | |
puncFields := strings.Split(puncSet, "") | |
puncNameFields := make([]string, 0) | |
for i := 0; i < _len; i++ { | |
puncLetter := strings.TrimSpace(letters[i] + puncFields[i]) | |
puncNameFields = append(puncNameFields, puncLetter) | |
} | |
punctuatedNames = append( | |
punctuatedNames, strings.Join(puncNameFields, "")+"@gmail.com") | |
} | |
for _, punctuatedName := range punctuatedNames { | |
fmt.Println(punctuatedName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment