Skip to content

Instantly share code, notes, and snippets.

@nazarov-yuriy
Created January 29, 2016 09:21
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 nazarov-yuriy/454ea1fd04ccc991918a to your computer and use it in GitHub Desktop.
Save nazarov-yuriy/454ea1fd04ccc991918a to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
my $str = "44+4 = 444/4-44/4+4/4";
sub main(){
for my $i (0,1,7,8,9,13) {
my $copy = $str;
my $char = "".substr($copy, $i, 1);
substr($copy, $i, 1) = "";
for my $j (0..20) {
my $copy1 = $copy;
substr($copy1, $j, 0) = $char;
my ($left, $right) = split '=', $copy1;
my $l = eval $left;
my $r = eval $right;
if(defined $l && defined $r && $l == $r){
print "\n$copy1\n";
print "$l = $r\n";
}
}
for my $j (0..20) {
my $copy1 = $copy;
substr($copy1, $j, 0) = "**$char";
my ($left, $right) = split '=', $copy1;
my $l = eval $left;
my $r = eval $right;
if(defined $l && defined $r && $l == $r){
print "\n$copy1\n";
print "$l = $r\n";
}
}
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment