package main

import (
	"fmt"
	"os"
	"regexp"
)

var testsuite = map[string]bool{
	"":           true,
	"0":          true,
	"00":         true,
	"A":          true,
	"ABCD":       true,
	"01":         true,
	"012":        true,
	"01234":      false,
	"012340":     true,
	"012345":     true,
	"0123456":    true,
	"0123401234": true,
}

func main() {
	// The following regexes are valid solutions:
	//   ^(.|..|...|....|[^0]....|.[^1]...|..[^2]..|...[^3].|....[^4]|......+)$
	//   ^(?!01234$).*$
	//   ^(?!01234$)(.|\n)*$
	pat := regexp.MustCompile("^(|.|..|...|....|[^0]....|.[^1]...|..[^2]..|...[^3].|....[^4]|......+)$")

	for input, match := range testsuite {
		var matches bool

		//res := pat.FindStringIndex(input)
		//matches = res != nil
		matches = pat.MatchString(input)

		if matches != match {
			fmt.Printf("FAIL for %s (shall be %t)\n", input, match)
		}
	}

	os.Exit(0)
}