fork download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4. use List::Util qw(reduce);
  5.  
  6. sub count { reduce{ $a->{$b}++; $a } {}, @_ }
  7. sub max_key { reduce{ $_[0]->{$a} > $_[0]->{$b} ? $a : $b } keys %{$_[0]} }
  8. sub f { max_key count split //, shift }
  9.  
  10. say f("aabaabbab");
  11.  
Success #stdin #stdout 0s 3848KB
stdin
Standard input is empty
stdout
a