More optimization

This commit is contained in:
Brian Buller 2018-12-05 09:39:41 -06:00
parent 9f64a7e63d
commit 20051e984a

View File

@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"log"
"math"
"os"
"strconv"
)
@ -74,7 +73,7 @@ func countByte(h []byte, n byte) int {
func react(v []byte) []byte {
var ret []byte
for i := 0; i < len(v); i++ {
if i < len(v)-1 && Abs(v[i], v[i+1]) == 32 {
if i < len(v)-1 && sameDecase(v[i], v[i+1]) {
i++
continue
}
@ -101,6 +100,6 @@ func Atoi(i string) int {
return ret
}
func Abs(val1, val2 byte) int {
return int(math.Abs(float64(val1) - float64(val2)))
func sameDecase(val1, val2 byte) bool {
return val1+32 == val2 || val2+32 == val1
}