a geicko-2 based round robin ranking system designed to test c++ battleship submissions battleship.dunkirk.sh
at main 1.0 kB view raw
1// Copyright 2022 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package cpu 6 7import "strconv" 8 9// parseRelease parses a dot-separated version number. It follows the semver 10// syntax, but allows the minor and patch versions to be elided. 11// 12// This is a copy of the Go runtime's parseRelease from 13// https://golang.org/cl/209597. 14func parseRelease(rel string) (major, minor, patch int, ok bool) { 15 // Strip anything after a dash or plus. 16 for i := range len(rel) { 17 if rel[i] == '-' || rel[i] == '+' { 18 rel = rel[:i] 19 break 20 } 21 } 22 23 next := func() (int, bool) { 24 for i := range len(rel) { 25 if rel[i] == '.' { 26 ver, err := strconv.Atoi(rel[:i]) 27 rel = rel[i+1:] 28 return ver, err == nil 29 } 30 } 31 ver, err := strconv.Atoi(rel) 32 rel = "" 33 return ver, err == nil 34 } 35 if major, ok = next(); !ok || rel == "" { 36 return 37 } 38 if minor, ok = next(); !ok || rel == "" { 39 return 40 } 41 patch, ok = next() 42 return 43}