chomp(my $be = ); chomp(my $n = ); chomp(my $af = ); my $be_num = $be =~ s/o/o/g; my $af_num = $af =~ s/o/o/g; my $result; if (not $be_num == $af_num){ $result = "SUCCESS"; } else { if ( $n == 0) { $result = $be ne $af ? "SUCCESS" : "FAILURE"; } elsif (not $n == 1) { $result = "FAILURE"; } else { my $impo = impossible($be); $result = $impo eq $af ? "SUCCESS" : "FAILURE"; } } print "$result\n"; sub impossible { my $t = shift; return "oxo" if $t eq "oxo"; return "xox" if $t eq "xox"; return "oox" if $t eq "xoo"; return "xoo" if $t eq "oox"; return "xxo" if $t eq "oxx"; return "oxx" if $t eq "xxo"; }