Anagram Detector
Function Name: areAnagrams
Description
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, the word 'listen' is an anagram of 'silent'.
Your task is to write a function 'areAnagrams' that takes two strings as parameters and returns a Boolean value. The function should determine whether the two strings are anagrams of each other, considering letter case and ignoring whitespace and punctuation.
Requirements
- The function 'areAnagrams' must take exactly two parameters of type string ('str1' and 'str2').
- The function must return a boolean value: true if 'str1' and 'str2' are anagrams of each other, false otherwise.
- Both input strings may contain whitespace and punctuation, which should be ignored during the anagram check.
- The comparison should be case-insensitive, meaning 'A' is considered the same as 'a'.
- The function must handle empty strings gracefully by returning false if either of the strings is empty after removing whitespace and punctuation.
- Do not use any sort of in-built 'anagram' functions provided by the language's standard library.
Examples
Example 1: areAnagrams('listen', 'silent') returns true.Example 2: areAnagrams('hello', 'billion') returns false.Example 3: areAnagrams('Dormitory', 'Dirty room') returns true.Example 4: areAnagrams('Conversation', 'Voices rant on') returns true.Example 5: areAnagrams('The eyes', 'They see') returns true.Example 6: areAnagrams('A decimal point', 'I'm a dot in place.') returns true.Example 7: areAnagrams('', 'Not empty') returns false.
Links
Fibonacci Checker
Sat Aug 31 2024
Write a function named `isFibonacciNumber` that determines if a given non-negative integer number is a Fibonacci number. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. That is, fib(0) = 0, fib(1) = 1, fib(2) = 1, fib(3) = 2, fib(4) = 3, fib(5) = 5, fib(6) = 8, and so on.Your function should take one integer parameter and return a boolean value indicating whether the number is part of the Fibonacci sequence.
Matrix Spiral Copy
Mon Sep 02 2024
Write a function that takes a 2D array (matrix) as input and returns a list of its elements in a spiral order. Start at the top-left corner of the input 2D array, go right and traverse the boundaries of the matrix in a clockwise spiral order, collecting elements until every element has been visited.