#!/usr/bin/perl
###########################################
# smm 
# 2005, Mike Schilli <cpan@perlmeister.com>
###########################################
use strict;
use warnings;
use Getopt::Std;
use Pod::Usage;
use Games::Puzzles::SendMoreMoney;
use Data::Dumper;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($INFO);

use vars qw($CVSVERSION);

$CVSVERSION = '$Revision: 1.3 $';

getopts("hv", \my %opts);
pod2usage() if $opts{h};
if($opts{v}) {
    my ($version) = $CVSVERSION =~ /(\d\S+)/;
    die "$0 $version\n";
}

my $solver = Games::Puzzles::SendMoreMoney->new(
        values    => [0..9],
        puzzle    => "SEND + MORE = MONEY",
        reporter  => sub { print Dumper($_[0]);
                           $Games::Puzzles::SendMoreMoney::STOP_SOLVER = 1;
                         },
        validator => sub { return 0 if $_[0]->{S} == 0;
                           return 0 if $_[0]->{M} == 0;
                           return 1; },
);

$solver->solve();

__END__

=head1 NAME

    smm - Calculate a solution for the SEND + MORE = MONEY puzzle

=head1 SYNOPSIS

    smm

=back

=head1 DESCRIPTION

This sample script will calculate a solution for the

    SEND + MORE = MONEY

problem by permutating single-digit values for the letters used in the
expression. It will arrive at a solution within a couple of seconds to
minutes, depending on your CPU's speed.

=head1 LEGALESE

Copyright 2005 by Mike Schilli, 
all rights reserved. This program is free 
software, you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 AUTHOR

2005, Mike Schilli <cpan@perlmeister.com>
