fork download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4. use List::Util qw(min);
  5.  
  6. sub short { min map{ $#{$_} } @_ }
  7.  
  8. sub f {
  9. my @l = map{ [reverse split //] } @_;
  10. return scalar grep{ $l[0]->[$_] eq $l[1]->[$_] } (0 .. short @l);
  11. }
  12.  
  13. foreach(
  14. [110, 119],
  15. [1234, 214],
  16. [567, 23],
  17. ){
  18. say join(', ', @{$_}), " -> ", f(@{$_});
  19. }
  20.  
Success #stdin #stdout 0s 3892KB
stdin
Standard input is empty
stdout
110, 119 -> 2
1234, 214 -> 2
567, 23 -> 0