#!/usr/bin/perl use strict; use warnings; # Assume that all my $iter = combo( 4, 1..4, 6..9 ); while ( my @combo = $iter->() ) { next if make_10( @combo ); print "@combo\n"; } sub make_10 { my @hand = @_; for ( 2 .. 4 ) { my $iter = combo( $_, @hand ); while ( my @combo = $iter->() ) { my $tot = 0; $tot += $_ for @combo; return 1 if $tot == 10; } } return 0; }