Retired

Character Frequency (retired)

3,638 of 6,074MysteriousMagenta

Description:

Description

Welcome, Warrior! In this kata, you will get a message and you will need to get the frequency of each and every character!

Explanation

Your function will be called char_freq/charFreq/CharFreq and you will get passed a string, you will then return a dictionary (object in JavaScript) with as keys the characters, and as values how many times that character is in the string. You can assume you will be given valid input.

Example

char_freq("I like cats") // Returns {'a': 1, ' ': 2, 'c': 1, 'e': 1, 'I': 1, 'k': 1, 'l': 1, 'i': 1, 's': 1, 't': 1}
charFreq("I like cats") // Returns {'a': 1, ' ': 2, 'c': 1, 'e': 1, 'I': 1, 'k': 1, 'l': 1, 'i': 1, 's': 1, 't': 1}
CharFreq("I like cats") => new Dictionary<char, int> {{'a', 1}, {' ', 2}, {'c', 1}, {'e', 1}, {'I', 1}, {'k', 1}, {'l', 1}, {'i', 1}, {'s', 1}, {'t', 1}}
Fundamentals
Strings

Similar Kata:

Stats:

CreatedDec 15, 2014
Warriors Trained8582
Total Skips205
Total Code Submissions13730
Total Times Completed6074
Python Completions3638
JavaScript Completions2163
C# Completions350
Total Stars126
% of votes with a positive feedback rating92% of 1024
Total "Very Satisfied" Votes891
Total "Somewhat Satisfied" Votes112
Total "Not Satisfied" Votes21
Ad
Contributors
  • MysteriousMagenta Avatar
  • jhoffner Avatar
  • srcrustaceo Avatar
  • Voile Avatar
  • Souzooka Avatar
Ad