Duplicate Character Counter in Mathematica

Published on 28 April 2022 (Updated: 02 February 2023)

Duplicate Character Counter in Mathematica

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.