aboutsummaryrefslogtreecommitdiff
path: root/pkg/verification/verification.go
blob: 487daf86ab2a40f502a370477f7b04529da70f76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package verification

import (
	"log"
	"sort"
)

var ServerNumbers []int

var Ticks uint32

func IsContinuous(arr []int) bool {
	if len(arr) == 0 {
		return false
	}

	// Sort the array first
	sort.Ints(arr)

	// Start with the first element
	prev := arr[0]

	for i := 1; i < len(arr); i++ {
		// Check if the current element is consecutive to the previous one
		if arr[i] != prev+1 {
			log.Printf("%d != %d", arr[i], prev+1)
			return false
		}
		prev = arr[i]
	}

	return true
}