Something like this?
$ cat 938978.pl #!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; my ($x, $y) = split /\s+/,$_; last if ! defined $y; print robo_1($x,$y), " <$x> <$y>\n"; } sub robo_1 { my %h; $h{$_}++ for split//,shift; $h{$_}-- for split//,shift; my $t=0; $t += ($_>0 ? $_ : -$_) for values %h; return $t; } __DATA__ 123456 abcdefghijkl ARF_ARF_ARF BARKBARKBARK doom gloom heartbreak anguish $ perl 938978.pl 18 <123456> <abcdefghijkl> 11 <ARF_ARF_ARF> <BARKBARKBARK> 3 <doom> <gloom> 13 <heartbreak> <anguish>
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: The sum of absolute differences in the counts of chars in two strings.
by roboticus
in thread The sum of absolute differences in the counts of chars in two strings.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |