Manafall Daily Quest

Frequency Counter

Function Name: calculateFrequency

Description

Write a function that takes a string as its only parameter. Your function should return a mapping of each unique character to its frequency in the string. The frequency is defined as the number of times a character appears in the string. The function should ignore casing, meaning that 'a' and 'A' are considered the same character, and spaces and punctuation should be ignored. Your solution should not use any third-party libraries and should optimize for readability and efficiency.

Requirements

  • The function must take exactly one parameter: the input string.
  • The function should return a dictionary (or equivalent hashmap data structure) where the keys are the unique characters and the values are the counts of those characters in the string.
  • Character comparison should be case-insensitive ('A' is the same as 'a').
  • Ignore spaces, digits, and punctuation. Only alphabetic characters should be counted.
  • The function should handle empty strings gracefully, returning an empty dictionary.
  • Write at least three test cases for your function: one with a standard string, one with mixed casing and punctuation, and one that's an empty string.

Examples

For example, if the function is given the string 'Hello, world!', it should return {'h': 1, 'e': 1, 'l': 3, 'o': 2, 'w': 1, 'r': 1, 'd': 1}.

Links

https://en.wikipedia.org/wiki/Letter_frequency

Balanced Parentheses

Fri Oct 04 2024

Write a function called 'checkBalancedParentheses' that takes a string containing only parentheses (i.e., '(', ')', '[', ']', '{', '}') and determines if the parentheses in the string are balanced. A string has balanced parentheses if each type of parenthesis is closed in the correct order. You may ignore any characters other than the six valid parentheses characters.

Prev Quest

CircularQueue

Sun Oct 06 2024

In this challenge, you are tasked with implementing a Circular Queue data structure. The circular queue is a linear data structure that follows the First In First Out (FIFO) principle but also connects the last position back to the first position to make a circle. It is ideal for scenarios where the queue needs to be reset after it reaches the end.Your implementation should support the following operations: enqueue, which inserts an element at the rear of the queue; dequeue, which removes and returns the element from the front of the queue; peek, which returns the front-most element without removing it from the queue; and isEmpty, which checks whether the queue is empty.

Next Quest