A pleasing number (according to this definition) is a number that can be passed through the following process (let's use
41802000 as an example):
- Separate the trailing identical numbers (
41802000 => [41802, 000])
- Sort the first half of the digits and take the maximum (
[41802, 000] => [8, 000])
- Take the length of the final element. Call the resultant elements A and B (
[8, 000] => A=8, B=3)
- Is NB = A for any integer
Truein this example; 23 = 8)
If the input results in
True from the following process, it is considered pleasing.
Your task is to take an integer
x, and output whether
x is a pleasing number. You can output any two distinct values for truthy and falsey, but please state what you're using in your answer.
x is guaranteed to have at least two distinct digits (e.g.
111 is an invalid input). As with most challenges, you may take
x as a string, or a list of digits.
This is a code-golf so shortest code in bytes wins.
Input Output 41802000 1 100 1 123456788 0 451111111 0 234543454545444 0 12 1 41902000 0 92599 1