Last active
June 10, 2022 21:51
-
-
Save WesleiRamos/d6824482227dcca7546ebc145a41e9be to your computer and use it in GitHub Desktop.
A simple match schedule algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
times := []string{"Corinthians", "Londrina", "Operário", "Leicester"} | |
calendario := [][][]string{} | |
lenTimes := len(times) | |
lenTimes2 := lenTimes / 2 | |
for y := 1; y < lenTimes; y++ { | |
rodada := [][]string{} | |
for i, x := 0, lenTimes2; i < lenTimes2; i, x = i+1, x+1 { | |
rodada = append(rodada, []string{times[i], times[x]}) | |
} | |
calendario = append(calendario, rodada) | |
t := y + 1 | |
if t == lenTimes { | |
t = 0 | |
} | |
times[y], times[t] = times[t], times[y] | |
} | |
for _, rodada := range calendario { | |
for _, _times := range rodada { | |
fmt.Printf("%s x %s\n", _times[0], _times[1]) | |
} | |
println("") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment