changed grid data type to bool, save mem and better perf

This commit is contained in:
2024-06-06 18:58:31 +02:00
parent a5dbd69976
commit ab22e0f4e2
5 changed files with 53 additions and 49 deletions

View File

@@ -9,17 +9,17 @@ import (
// a GOL rule
type Rule struct {
Definition string
Birth []int64
Death []int64
Birth []int
Death []int
}
// parse one part of a GOL rule into rule slice
func NumbersToList(numbers string) []int64 {
list := []int64{}
func NumbersToList(numbers string) []int {
list := []int{}
items := strings.Split(numbers, "")
for _, item := range items {
num, err := strconv.ParseInt(item, 10, 64)
num, err := strconv.Atoi(item)
if err != nil {
log.Fatalf("failed to parse game rule part <%s>: %s", numbers, err)
}