Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created May 1, 2013 20:05
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 tadzik/5497945 to your computer and use it in GitHub Desktop.
Save tadzik/5497945 to your computer and use it in GitHub Desktop.
sub a{my%s;for(@_){return if $s{$_}++}1}sub d{($r,$v)=@_;@d=map{$_-++$i}@$r,$v;@e=map{$_+ ++$j}@$r,$v;a(@d)&&a(@e)}sub t{my($n,$w)=@_;if($n>8){print"[",(join",",@$w),"]\n";return}for(1..8){next if!a(@$w,$_)or!d($w,$_);t($n+1,[@$w,$_])}}t(1,[])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment