package Hack::Natas::IncrementalSearch;
use strict;
use warnings;
use v5.16.0;
our $VERSION = '0.003'; # VERSION
# ABSTRACT: do incremental searches for some Natas challenges

use Types::Standard qw(Int Str);
use Type::Utils qw(class_type);
use Moo::Role;
requires qw(

has password_so_far => (
    is      => 'rw',
    isa     => Str,
    default => sub { '' },

sub run {
    my $self = shift;

    foreach my $pos (1 .. $self->password_length) {
        $self->password_so_far( $self->password_so_far . $self->guess_next_char($pos) );
    $self->password( $self->password_so_far );




=encoding utf-8

=head1 NAME

Hack::Natas::IncrementalSearch - do incremental searches for some Natas challenges

=head1 VERSION

version 0.003


This is a role for incrementally guessing the password in one-character
slices. It provides a C<password_so_far> attribute, which is used to
build up the full password. It requires that consumers have:

=over 4

=item * password_length

An integer which tells us how long the password is, so the search will stop
once we have the whole thing.

=item * guess_next_char

A method which, when called with the current position in the password, returns
the next character.


=head1 METHODS

=head2 run

This is the only method you need to call. It will do the search, and once
C<password_length> characters of the password have been guessed using
C<guess_next_char>, the C<password> attribute will be set.


The project homepage is L<>.

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<> to find a CPAN
site near you, or see L<>.

=head1 SOURCE

The development version is on github at L<>
and may be cloned from L<git://>


You can make new bug reports, and view existing ones, through the
web interface at L<>.

=head1 AUTHOR

Mike Doherty <>


This software is copyright (c) 2013 by Mike Doherty.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.