Duplicate Character Counter in Mathematica

Published on 21 January 2023 (Updated: 21 January 2023)

Welcome to the Duplicate Character Counter in Mathematica page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

(* Code *)

(* The inner function does the work, returning the output as a Mathematica list: *)

duplicateCharacterCounter = Function[{s},
   Select[
    {First[#], Length[#]} & /@ Gather[Characters[s]],
    #[[2]] > 1 &]];

(* The outer function performs the output text formatting: *)

duplicateCharacterCounterMain = s \[Function]
   Print[#[[1]], ": ", #[[2]]] & /@ duplicateCharacterCounter[s];


(* Valid Tests *)

duplicateCharacterCounterMain /@ {
   "goodbyeblues",
   "abba",
   "aAbB"
   };


(* Invalid Tests *)

Duplicate Character Counter in Mathematica was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.