Skip to content

Instantly share code, notes, and snippets.

@evdb
Created January 17, 2016 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evdb/68e00fcb6475405bc76c to your computer and use it in GitHub Desktop.
Save evdb/68e00fcb6475405bc76c to your computer and use it in GitHub Desktop.
use integer;
@A = split //, <>;
sub R {
for $i ( 0 .. 80 ) {
next if $A[$i];
my %t = map {
$_ / 9 == $i / 9
|| $_ % 9 == $i % 9
|| $_ / 27 == $i / 27 && $_ % 9 / 3 == $i % 9 / 3
? $A[$_]
: 0 => 1
} 0 .. 80;
R( $A[$i] = $_ ) for grep { !$t{$_} } 1 .. 9;
return $A[$i] = 0;
}
die @A;
}
R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment