Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
5f49a09ab4 | |||
42ccf3c812 | |||
2fa6aef836 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@
|
|||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
*.zip
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
46
answer.txt
46
answer.txt
@@ -1,46 +0,0 @@
|
|||||||
UPC
|
|
||||||
200033148770
|
|
||||||
200042041350
|
|
||||||
200042041400
|
|
||||||
200042064910
|
|
||||||
200047796200
|
|
||||||
200059594110
|
|
||||||
200059660970
|
|
||||||
200065290180
|
|
||||||
200065290220
|
|
||||||
200065290310
|
|
||||||
200065290340
|
|
||||||
200065290370
|
|
||||||
200066707320
|
|
||||||
200069556670
|
|
||||||
200072791220
|
|
||||||
0075849385857
|
|
||||||
200072791320
|
|
||||||
200072791380
|
|
||||||
200072791470
|
|
||||||
200072950140
|
|
||||||
200079186270
|
|
||||||
200079343740
|
|
||||||
200081451640
|
|
||||||
200081630310
|
|
||||||
200106953220
|
|
||||||
200156488680
|
|
||||||
200157056340
|
|
||||||
200168095820
|
|
||||||
200168979440
|
|
||||||
200172490020
|
|
||||||
200177334550
|
|
||||||
200177780700
|
|
||||||
200177788230
|
|
||||||
327582805540
|
|
||||||
337582889920
|
|
||||||
357582840140
|
|
||||||
357582843530
|
|
||||||
357582850030
|
|
||||||
477039522210
|
|
||||||
477039522200
|
|
||||||
482000077030
|
|
||||||
482000077040
|
|
||||||
482000077090
|
|
||||||
647582802920
|
|
||||||
647582804700
|
|
79
main.go
79
main.go
@@ -71,46 +71,51 @@ func main() {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
for _, upc := range upcs {
|
for _, upc := range upcs {
|
||||||
checkForNonStartingNumber := regex.MatchString(upc)
|
if len(upc) > 0 {
|
||||||
|
checkForNonStartingNumber := regex.MatchString(upc)
|
||||||
|
|
||||||
|
if checkForNonStartingNumber {
|
||||||
|
gtins = append(gtins, upc)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if isNumeric(upc) {
|
||||||
|
gtins = append(gtins, upc)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lower case the E
|
||||||
|
upc = strings.ToLower(upc)
|
||||||
|
// Split scientific notation at the e+ point
|
||||||
|
upcArray := strings.Split(upc, "e+")
|
||||||
|
|
||||||
|
fmt.Println(upcArray)
|
||||||
|
|
||||||
|
// Create separate variables for the split values
|
||||||
|
workingUpc := upcArray[0]
|
||||||
|
upcENumber := upcArray[1]
|
||||||
|
|
||||||
|
// At one to the scientific notation length to allow for the decimal point to be removed
|
||||||
|
upcLength, err := strconv.Atoi(upcENumber)
|
||||||
|
Error(err)
|
||||||
|
upcLength = upcLength + 1
|
||||||
|
|
||||||
|
// Remove the decimal point
|
||||||
|
workingUpc = strings.ReplaceAll(workingUpc, ".", "")
|
||||||
|
|
||||||
|
// Append 0 to UPC to match notation length
|
||||||
|
for len(workingUpc) < upcLength {
|
||||||
|
workingUpc = workingUpc + "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
upc = workingUpc
|
||||||
|
|
||||||
if checkForNonStartingNumber {
|
|
||||||
gtins = append(gtins, upc)
|
gtins = append(gtins, upc)
|
||||||
continue
|
checkBar.Add(1)
|
||||||
|
} else {
|
||||||
|
gtins = append(gtins, "")
|
||||||
|
checkBar.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isNumeric(upc) == true {
|
|
||||||
gtins = append(gtins, upc)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lower case the E
|
|
||||||
upc = strings.ToLower(upc)
|
|
||||||
// Split scientific notation at the e+ point
|
|
||||||
upcArray := strings.Split(upc, "e+")
|
|
||||||
|
|
||||||
fmt.Println(upcArray)
|
|
||||||
|
|
||||||
// Create separate variables for the split values
|
|
||||||
workingUpc := upcArray[0]
|
|
||||||
upcENumber := upcArray[1]
|
|
||||||
|
|
||||||
// At one to the scientific notation length to allow for the decimal point to be removed
|
|
||||||
upcLength, err := strconv.Atoi(upcENumber)
|
|
||||||
Error(err)
|
|
||||||
upcLength = upcLength + 1
|
|
||||||
|
|
||||||
// Remove the decimal point
|
|
||||||
workingUpc = strings.ReplaceAll(workingUpc, ".", "")
|
|
||||||
|
|
||||||
// Append 0 to UPC to match notation length
|
|
||||||
for len(workingUpc) < upcLength {
|
|
||||||
workingUpc = workingUpc + "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
upc = workingUpc
|
|
||||||
|
|
||||||
gtins = append(gtins, upc)
|
|
||||||
checkBar.Add(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
answerBar := progressbar.NewOptions(len(gtins),
|
answerBar := progressbar.NewOptions(len(gtins),
|
||||||
|
Reference in New Issue
Block a user