github.com/LanderTome/numerologyCalculator@v1.0.2/numerology/karmicLesson.go (about)

     1  // Copyright 2021 Robert D. Wukmir
     2  // This file is subject to the terms and conditions defined in
     3  // the LICENSE file, which is part of this source code package.
     4  //
     5  // Unless required by applicable law or agreed to in writing,
     6  // software distributed under the License is distributed on an
     7  // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
     8  // either express or implied. See the License for the specific
     9  // language governing permissions and limitations under the
    10  // License.
    11  
    12  package numerology
    13  
    14  import (
    15  	"sort"
    16  )
    17  
    18  // KarmicLessonResults packages the key information from the Numbers function.
    19  type KarmicLessonResults struct {
    20  	// Numbers is a slice of int of all the numbers that are not found in the Lookup.
    21  	Numbers []int `json:"karmic_lessons"`
    22  }
    23  
    24  // karmicLessons calculates the numerology number(s) that do not show up in a given name.
    25  func karmicLessons(counts map[int32]int) (results KarmicLessonResults) {
    26  	// Iterate over counts to find the numbers that are missing.
    27  	r := []int{}
    28  	for k, v := range counts {
    29  		// Look for numbers with a count of 0.
    30  		if v == 0 {
    31  			r = append(r, int(k))
    32  		}
    33  	}
    34  	sort.Ints(r)
    35  	return KarmicLessonResults{r}
    36  }