Skip to content

Instantly share code, notes, and snippets.

@kirkegaard
Created December 27, 2025 00:00
Show Gist options
  • Select an option

  • Save kirkegaard/1f6e0695dd97c000a8e952728af8e774 to your computer and use it in GitHub Desktop.

Select an option

Save kirkegaard/1f6e0695dd97c000a8e952728af8e774 to your computer and use it in GitHub Desktop.
cassidoo #436
package main
import (
"fmt"
)
var sequences = [][]int{
[]int{},
[]int{1},
[]int{1, 1},
[]int{1, 2, 1},
[]int{10, 5, 10, 5, 10},
[]int{2, 2, 3, 3},
[]int{5, 4, 3, 5, 4, 3},
}
func isAlternating(sequence []int) bool {
if len(sequence) < 2 {
return true
}
for i, value := range sequence {
if value != sequence[i%2] {
return false
}
}
return true
}
func main() {
for _, sequence := range sequences {
fmt.Println(isAlternating(sequence))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment