Unique Character Mapping
Function Name: uniqueCharMap
Description
Write a function called `uniqueCharMap` which takes a single string as its parameter.
The function should return a map (or dictionary) where each key is a unique character from the string, and the value is the number of times that character appears in the string.
The function should ignore case, treating uppercase and lowercase characters as the same.
The result should be sorted by the keys in alphabetical order.
Non-letter characters should be included.
Spaces should be counted and mapped as well.
If the input string is empty, the function should return an empty map.
Requirements
- Function takes one parameter, a string.
- The function must return a map/dictionary.
- Keys in the map are unique characters from the string, case-insensitive.
- Values are the counts of said characters' occurrences in the string.
- The map should be sorted by keys alphabetically.
- All characters including non-letter ones are considered.
- Include spaces in the count and the resulting map.
- If the string is empty, return an empty map.
Examples
Given the string 'Example', `uniqueCharMap('Example')` would return `{ 'a': 1, 'e': 2, 'l': 1, 'm': 1, 'p': 1, 'x': 1 }` as the map, since it ignores case and 'e' occurs twice.If the function is called with an empty string like `uniqueCharMap('')`, it should return `{}`.
Simple Inventory Counter
Tue Jul 30 2024
Write a function `countInventory` that takes in a list of items sold in a store over the course of a day.The input list consists of strings, with each string representing an item name.The function should return a dictionary or map where each key-value pair represents the item and the number of times it was sold.The items should be accounted for in a case-insensitive manner.If the list is empty, return an empty dictionary or map.
Prime Factorization
Thu Aug 01 2024
The task is to write a function named 'primeFactorize that takes a single integer parameter and returns an array or list of its prime factors (including multiplicity).A prime factor is a factor that is a prime number, and prime factorization of a number is a list of prime numbers that multiply to the number.The function should handle erroneous and edge cases gracefully, such as negative inputs, zero, and one, by returning an empty list or array.