#!/usr/bin/perl -wT

use strict;
use warnings;

sub main {
	# The following regexes are valid solutions:
	#   ^(.|..|...|....|[^0]....|.[^1]...|..[^2]..|...[^3].|....[^4]|......+)$
	#   ^(?!01234$).*$
	#   ^(?!01234$)(.|\n)*$

	my %testsuite = (
		"" =>           1,
		"0" =>          1,
		"00" =>         1,
		"A" =>          1,
		"ABCD" =>       1,
		"01" =>         1,
		"012" =>        1,
		"01234" =>      0,
		"012340" =>     1,
		"012345" =>     1,
		"0123456" =>    1,
		"0123401234" => 1
	);

	my $pat = qr/^(|.|..|...|....|[^0]....|.[^1]...|..[^2]..|...[^3].|....[^4]|......+)$/;

	for my $input (keys %testsuite) {
	    if ($input !~ $pat and $testsuite{$input}) {
	    	print "FAIL for $input (should be " . $testsuite{$input} . ")\n";
	    }
	}
}

main();