Simple Inventory Counter
Function Name: countInventory
Description
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.
Requirements
- The function `countInventory` must take exactly one parameter: a list (or equivalent data structure) of strings.
- The function must be case-insensitive when counting items.
- The return value must be a dictionary or map data structure.
- The keys in the resulting dictionary or map should be in lowercase.
- The function should handle an empty list input by returning an empty dictionary or map.
- Function should not use any third-party modules or libraries.
Examples
If the function is given the following list: ['apple', 'Banana', 'APPLE', 'banana', 'CANDY'], the expected return should be {'apple': 2, 'banana': 2, 'candy': 1}.If the function is given an empty list: [], the expected return should be {}.
File Path Simplification
Mon Jul 29 2024
Implement a function that takes a string representing an absolute file path in a Unix-style file system, and returns the simplified canonical path. In a Unix-like operating system, a canonical path is the simplest absolute path that points to the same location as the original path.A canonical path has the following properties:- The path starts with a single slash ('/').- Any two directories are separated by a single slash ('/').- The path does not end with a trailing '/'.- The path only contains the directories on the path from the root directory to the target file or directory, with the exception of '.' or '..' which are interpreted as current and parent directory respectively.
Unique Character Mapping
Wed Jul 31 2024
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.