Note that this is similar to my other challenge, but it is widened to be similar to most challenges (input -> truthy/falsey), instead of asking you all to brute force something. If this makes it a dupe, let me know, but I posted it on Sandbox and asked on chat, and didn't get any negative responses.
Input will be a "word" consisting of
'. The case is important. Instead of my previous challenge, where you run through all permutations, in this challenge, you will be given a permutation. Your program's response on invalid input does not matter. Input can be taken in reasonable text input formats, and can contain a trailing newline if required.
Output will be a standard truthy/falsey values on if the permutation can be split in half. A permutation can be split in half if the width values (see below) of one half of the word equal the point values of the other half, or if the same is true if the middle word is removed. Trailing newlines allowed if required.
Please note that "half" does not mean that you have moved halfway into the string. "Half" means that the points on both sides are equal.
W is 5 points.
i is 1 point. Splitting the permutation
Wiiiii in half will result in
W | iiiii, with 5 points on each side of the
T is 3 points. Splitting the permutation
TTTT in half will result in
TT | TT, with 6 points on each side of the
w is 4 points. a is 3 points. Splitting the permutation
waw in half will result in
w (a) w, with 5.5 points on each side. The points from
a are distributed to both sides, as
a is split in half.
See the test cases for more clarification.
Width Characters 1 i l I ' 2 f j r t - 3 a b c d e g h k n o p q s u v x y z 4 m w A B C D E F G H J K L N O P Q R S T U V X Y Z 5 M W
( ) indicate that the permutation can be split if the character inside the parantheses is cut in half.
| indicates that the permutation can be split in between those two letters.
Input : Output : Visualization
a : truthy : (a) ab : truthy : a|b Ab : falsey AB : truthy : A|B r- : truthy : r|- iiiiw : truthy : iiii|w iiiiiiW : truthy : iiiii(i)W STEPHEN : truthy : STE(P)HEN STEphen : truthy : STE|phen STEpheN : falsey splitwoRdS : truthy : splitw|oRdS
And here's a visualization for
s p l i t w | o R d S 3 3 1 1 2 4 3 4 3 4