Created
January 29, 2016 09:21
-
-
Save nazarov-yuriy/454ea1fd04ccc991918a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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