Created
January 17, 2016 15:05
-
-
Save evdb/cf85bc05f45d17503047 to your computer and use it in GitHub Desktop.
This file contains 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
$a = 8; | |
$G{ int( ++$a / 9 ) . $a % 9 + 1 } = $_ for split //, <>; | |
@A = 1 .. 9; | |
sub c { | |
int( ( $_[0] - 1 ) / 3 ) * 3; | |
} | |
sub G { | |
for $y (@A) { | |
for $x (@A) { | |
$p = $t = $G{ my $c = $y . $x } && next; | |
$t .= $G{ $_ . $x } . $G{ $y . $_ } for @A; | |
for $f ( 1 .. 3 ) { $t .= $G{ c($y) + $f . c($x) + $_ } for 1 .. 3 } | |
G( $G{$c} = $_ ) && return for grep $t !~ m/$_/, @A; | |
return $G{$c} = 0; | |
} | |
} | |
die map { $G{$_} } 9 .. 99; | |
} | |
G |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment