1. Cardinality Sorting
The binary cardinality of a number is the total number of 1's it contains in its binary representation. For example, the decimal integer 20 corresponds to the binary number 10100, and there are 2 1's in the binary representation so its binary cardinality is 2. Given an array of decimal integers, sort it in ascending order first by binary cardinality, then by decimal value if there is a tie in cardinality. Return the resulting array. For instance, given the array [1, 2, 3, 4], the sorted array by binary cardinality would be [2, 4, 1, 3]. Write a function to implement this sorting method.
2. Longest Even Length Word
Consider a string, sentence, of words separated by spaces where each word is a substring consisting of English alphabetic letters only. Find the first word in the sentence that has a length which is both an even number and greater than or equal to the length of any other word of even length in the sentence. If there are multiple words meeting the criteria, return the one which occurs first in the sentence. For example, for the sentence 'Time to write great code', the longest even length words are 'Time' and 'code'. The one that occurs first is 'Time', which is the answer to return. Write a function to implement this logic and return the first longest even length word or the string '00' if there are no even length words.
3. Subarray Sum
Given an array of integers, find the sum of all elements of all subarrays of that array. For example, a three-element array [4, 5, 6] can be made into the following subarrays: [4], [5], [6], [4, 5], [5, 6], and [4, 5, 6]. The sum of all elements of these subarrays is 4+5+6+(4+5)+(5+6)+(4+5+6).
4. Rearranging a Word
Given a word, return the next alphabetically greater permutation of that word. If there is no greater permutation available, return the string 'no answer'. The word contains characters in the set ascii[a-z], and its length is between 2 and 10^4 characters.
5. Break a Palindrome
Given a palindrome, you are required to change exactly one character of the string to another character in the range ascii[a-z] so that the resulting string is lower alphabetically than the initial string, is the lowest value string alphabetically that can be created from the original palindrome after making only one change, and is not a palindrome itself. If it's not possible to meet the criteria, return the string 'IMPOSSIBLE'.