#!/usr/bin/env raku sub percentage-of-character ($str,:$char) { $str.comb andthen .Bag andthen .{$char}/.total andthen 100 * $_ andthen .round } multi MAIN (Bool :test($)!) { use Test; is percentage-of-character('perl',:char), 25; is percentage-of-character('java',:char), 50; is percentage-of-character('python',:char), 0; is percentage-of-character('ada',:char), 67; is percentage-of-character('ballerina',:char), 22; is percentage-of-character('analitik',:char), 13; done-testing; } multi MAIN ($str,:$char) { say percentage-of-character $str,:$char }