Note: This is inspired by this question by @Willbeing where task was to count the number of perfect plates of a certain length, but it's slightly different.
We call a perfect licence plate that plate whose text satisfies the following conditions:
- It consists of characters, which can either be uppercase letters(
[A-Z]) or digits(
- Summing the positions of its letters in the English alphabet, 1-indexed (i.e:
A=1,B=2,...,Z=26) gives an integer n
- Getting each chunk of digits, summing them and then multiplying all the results gives the same result, n
- n is a perfect square (e.g:
A nearly perfect licence plate meets the conditions for a perfect licence plate, except that n is not a perfect square.
A string representing the text of the licence plate, taken as input in any standard form, except for hardcoding.
If the given string represents a nearly perfect licence plate, return a truthy value (e.g:
1), otherwise return a falsy value (e.g:
0). Any standard form of output is accepted while taking note that this loopholes are strictly forbidden.
licence plate -> output A1B2C3 -> 1 A + B + C = 1 + 2 + 3 = 6 1 * 2 * 3 = 6 6 is not a perfect square, 6 = 6 => nearly perfect plate 01G61 -> 1 (0 + 1) * (6 + 1) = 7 G = 7 7 is not a perfect square, 7 = 7 => nearly perfect plate 11BB2 -> 0 (1 + 1) * 2 = 4 B + B = 2 + 2 = 4 4 = 4, but 4 is the square of 2 => perfect license plate (not what we want) 67FF1 -> 0 (6 + 7) * 1 = 13 F + F = 6 + 6 = 12 12 != 13 => not perfect at all!
This is code-golf, so the shortest answer in bytes wins!